diff --git a/config.json b/config.json index 1dc0877c..cb559a22 100644 --- a/config.json +++ b/config.json @@ -20,8 +20,7 @@ }, "files": { "solution": [ - "src/lib.cairo", - "Scarb.toml" + "src/lib.cairo" ], "test": [ "tests/%{snake_slug}.cairo" @@ -31,6 +30,9 @@ ], "exemplar": [ ".meta/exemplar.cairo" + ], + "invalidator": [ + "Scarb.toml" ] }, "exercises": { @@ -84,7 +86,7 @@ }, { "slug": "lucians-luscious-lasagna", - "name": "Lucians Luscious Lasagna", + "name": "Lucian's Luscious Lasagna", "uuid": "8302f8de-14d7-45dd-9a65-812bc1ed5464", "practices": [ "functions" diff --git a/exercises/concept/low-power-embedded-game/.meta/config.json b/exercises/concept/low-power-embedded-game/.meta/config.json index f294a0f3..275f6557 100644 --- a/exercises/concept/low-power-embedded-game/.meta/config.json +++ b/exercises/concept/low-power-embedded-game/.meta/config.json @@ -4,8 +4,7 @@ ], "files": { "solution": [ - "src/lib.cairo", - "Scarb.toml" + "src/lib.cairo" ], "test": [ "tests/low_power_embedded_game.cairo" diff --git a/exercises/concept/low-power-embedded-game/src/lib.cairo b/exercises/concept/low-power-embedded-game/src/lib.cairo index e4852e03..736b4582 100644 --- a/exercises/concept/low-power-embedded-game/src/lib.cairo +++ b/exercises/concept/low-power-embedded-game/src/lib.cairo @@ -1,14 +1,14 @@ #[generate_trait] pub impl DivmodImpl of DivmodTrait { fn divmod(self: @u16, divisor: u16) -> (u16, u16) { - panic!("implement `fn divmod`") + panic!("implement `divmod`") } } #[generate_trait] pub impl EvensImpl, +Copy> of EvensTrait { fn evens(self: @Array) -> Array { - panic!("implement `fn evens`") + panic!("implement `evens`") } } @@ -17,6 +17,6 @@ pub type Position = (i16, i16); #[generate_trait] pub impl PositionImpl of PositionTrait { fn manhattan(self: @Position) -> i16 { - panic!("implement `fn manhattan`") + panic!("implement `manhattan`") } } diff --git a/exercises/practice/allergies/.meta/config.json b/exercises/practice/allergies/.meta/config.json index 1388c5b4..71a1c287 100644 --- a/exercises/practice/allergies/.meta/config.json +++ b/exercises/practice/allergies/.meta/config.json @@ -4,14 +4,16 @@ ], "files": { "solution": [ - "src/lib.cairo", - "Scarb.toml" + "src/lib.cairo" ], "test": [ "tests/allergies.cairo" ], "example": [ ".meta/example.cairo" + ], + "invalidator": [ + "Scarb.toml" ] }, "blurb": "Given a person's allergy score, determine whether or not they're allergic to a given item, and their full list of allergies.", diff --git a/exercises/practice/allergies/src/lib.cairo b/exercises/practice/allergies/src/lib.cairo index 6a8855b0..47e3b260 100644 --- a/exercises/practice/allergies/src/lib.cairo +++ b/exercises/practice/allergies/src/lib.cairo @@ -16,16 +16,17 @@ pub enum Allergen { #[generate_trait] pub impl AllergiesImpl of AllergiesTrait { fn new(score: u32) -> Allergies { - panic!("Given the '{score}' score, construct a new Allergies struct.") + // construct a new Allergies struct + panic!("implement `new`") } fn is_allergic_to(self: @Allergies, allergen: @Allergen) -> bool { - panic!("Determine if the patient is allergic to the '{allergen:?}' allergen.") + // determine whether the person is allergic to '{allergen}' + panic!("implement `is_allergic_to`") } fn allergies(self: @Allergies) -> Array { - panic!( - "Return the list of allergens contained within the score with which the Allergies struct was made." - ) + // return a list of allergies based on the person's allergy score + panic!("implement `allergies`") } } diff --git a/exercises/practice/anagram/.meta/config.json b/exercises/practice/anagram/.meta/config.json index 5a3b33d2..cb0ceb36 100644 --- a/exercises/practice/anagram/.meta/config.json +++ b/exercises/practice/anagram/.meta/config.json @@ -4,14 +4,16 @@ ], "files": { "solution": [ - "src/lib.cairo", - "Scarb.toml" + "src/lib.cairo" ], "test": [ "tests/anagram.cairo" ], "example": [ ".meta/example.cairo" + ], + "invalidator": [ + "Scarb.toml" ] }, "blurb": "Given a word and a list of possible anagrams, select the correct sublist.", diff --git a/exercises/practice/anagram/.meta/example.cairo b/exercises/practice/anagram/.meta/example.cairo index 94df90d5..8c38c6f2 100644 --- a/exercises/practice/anagram/.meta/example.cairo +++ b/exercises/practice/anagram/.meta/example.cairo @@ -41,14 +41,14 @@ impl SetEq of PartialEq { } } -pub fn anagrams_for(word: @ByteArray, inputs: @Set) -> Set { +pub fn anagrams_for(word: @ByteArray, candidates: @Set) -> Set { let mut word_sorted = @sort_ignore_case(word); let mut anagrams = Set { values: array![] }; - let mut i = inputs.values.len(); + let mut i = candidates.values.len(); while i != 0 { i -= 1; - let candidate = inputs.values[i]; + let candidate = candidates.values[i]; let is_anagram = word.len() == candidate.len() && IgnoreCase::ne(word, candidate) diff --git a/exercises/practice/anagram/src/lib.cairo b/exercises/practice/anagram/src/lib.cairo index a4dff538..7eedb1d9 100644 --- a/exercises/practice/anagram/src/lib.cairo +++ b/exercises/practice/anagram/src/lib.cairo @@ -4,20 +4,24 @@ struct Set {} #[generate_trait] pub impl SetImpl of SetTrait { fn new(values: Array) -> Set { - panic!() + // construct a new Set struct + panic!("implement `new`") } } impl SetEq of PartialEq { fn eq(lhs: @Set, rhs: @Set) -> bool { - panic!() + // determine whether the two Sets are equal + panic!("implement `eq`") } fn ne(lhs: @Set, rhs: @Set) -> bool { - panic!() + // determine whether the two Sets are NOT equal + panic!("implement `ne`") } } -pub fn anagrams_for(word: @ByteArray, inputs: @Set) -> Set { - panic!() +pub fn anagrams_for(word: @ByteArray, candidates: @Set) -> Set { + // construct a Set of words from the set of candidates that are anagrams of {word} + panic!("implement `anagrams_for`") } diff --git a/exercises/practice/armstrong-numbers/.meta/config.json b/exercises/practice/armstrong-numbers/.meta/config.json index 64f0540c..054809ee 100644 --- a/exercises/practice/armstrong-numbers/.meta/config.json +++ b/exercises/practice/armstrong-numbers/.meta/config.json @@ -4,14 +4,16 @@ ], "files": { "solution": [ - "src/lib.cairo", - "Scarb.toml" + "src/lib.cairo" ], "test": [ "tests/armstrong_numbers.cairo" ], "example": [ ".meta/example.cairo" + ], + "invalidator": [ + "Scarb.toml" ] }, "blurb": "Determine if a number is an Armstrong number.", diff --git a/exercises/practice/armstrong-numbers/src/lib.cairo b/exercises/practice/armstrong-numbers/src/lib.cairo index 27d040ae..3326d0b2 100644 --- a/exercises/practice/armstrong-numbers/src/lib.cairo +++ b/exercises/practice/armstrong-numbers/src/lib.cairo @@ -1,3 +1,3 @@ pub fn is_armstrong_number(num: u128) -> bool { - panic!("true if {num} is an armstrong number") + panic!("implement `is_armstrong_number`") } diff --git a/exercises/practice/beer-song/.meta/config.json b/exercises/practice/beer-song/.meta/config.json index 148eac81..806d5b2f 100644 --- a/exercises/practice/beer-song/.meta/config.json +++ b/exercises/practice/beer-song/.meta/config.json @@ -4,14 +4,16 @@ ], "files": { "solution": [ - "src/lib.cairo", - "Scarb.toml" + "src/lib.cairo" ], "test": [ "tests/beer_song.cairo" ], "example": [ ".meta/example.cairo" + ], + "invalidator": [ + "Scarb.toml" ] }, "blurb": "Produce the lyrics to that beloved classic, that field-trip favorite: 99 Bottles of Beer on the Wall.", diff --git a/exercises/practice/beer-song/src/lib.cairo b/exercises/practice/beer-song/src/lib.cairo index eadcd452..56a45bb9 100644 --- a/exercises/practice/beer-song/src/lib.cairo +++ b/exercises/practice/beer-song/src/lib.cairo @@ -1,11 +1,14 @@ pub fn verse(n: u32) -> ByteArray { - panic!("emit verse {n}") + // return verse {n} + panic!("implement `verse`") } pub fn verses(start: u32, take_count: u32) -> ByteArray { - panic!("sing {take_count} verses from {start}") + // return {take_count} verses from {start} + panic!("implement `verses`") } pub fn song() -> ByteArray { - panic!("sing the whole song") + // return the whole song + panic!("implement `song`") } diff --git a/exercises/practice/binary-search/.meta/config.json b/exercises/practice/binary-search/.meta/config.json index 61361e5e..d0811170 100644 --- a/exercises/practice/binary-search/.meta/config.json +++ b/exercises/practice/binary-search/.meta/config.json @@ -4,14 +4,16 @@ ], "files": { "solution": [ - "src/lib.cairo", - "Scarb.toml" + "src/lib.cairo" ], "test": [ "tests/binary_search.cairo" ], "example": [ ".meta/example.cairo" + ], + "invalidator": [ + "Scarb.toml" ] }, "blurb": "Implement a binary search algorithm.", diff --git a/exercises/practice/binary-search/src/lib.cairo b/exercises/practice/binary-search/src/lib.cairo index 89f0534e..14777869 100644 --- a/exercises/practice/binary-search/src/lib.cairo +++ b/exercises/practice/binary-search/src/lib.cairo @@ -1,5 +1,5 @@ pub fn find(search_array: @Array, value: usize) -> Option { - panic!( - "Using the binary search algorithm, find the element '{value}' in the array '{search_array:?}' and return its index." - ) + // use the binary search algorithm to find the element '{value}' in the array '{search_array:?}' + // and return its index, otherwise return Option::None + panic!("implement `find`") } diff --git a/exercises/practice/clock/.meta/config.json b/exercises/practice/clock/.meta/config.json index f7a0c8e9..3ca54108 100644 --- a/exercises/practice/clock/.meta/config.json +++ b/exercises/practice/clock/.meta/config.json @@ -4,14 +4,16 @@ ], "files": { "solution": [ - "src/lib.cairo", - "Scarb.toml" + "src/lib.cairo" ], "test": [ "tests/clock.cairo" ], "example": [ ".meta/example.cairo" + ], + "invalidator": [ + "Scarb.toml" ] }, "blurb": "Implement a clock that handles times without dates.", diff --git a/exercises/practice/clock/src/lib.cairo b/exercises/practice/clock/src/lib.cairo index fea01685..854060e2 100644 --- a/exercises/practice/clock/src/lib.cairo +++ b/exercises/practice/clock/src/lib.cairo @@ -7,17 +7,20 @@ struct Clock { impl ClockDisplay of Display { fn fmt(self: @Clock, ref f: Formatter) -> Result<(), Error> { - panic!("implement `fmt` to define how the Clock should be displayed as a string") + // define how the Clock should be converted to a string + panic!("implement `fmt`") } } #[generate_trait] pub impl ClockImpl of ClockTrait { fn new(hour: i32, minute: i32) -> Clock { + // construct a new Clock struct panic!("implement `new`") } fn add_minutes(ref self: Clock, minutes: i32) -> Clock { + // adds {minutes} to the current Clock and returns the result as a new Clock panic!("implement `add_minutes`") } diff --git a/exercises/practice/custom-set/.meta/config.json b/exercises/practice/custom-set/.meta/config.json index b47aecfc..d38c57fd 100644 --- a/exercises/practice/custom-set/.meta/config.json +++ b/exercises/practice/custom-set/.meta/config.json @@ -4,14 +4,16 @@ ], "files": { "solution": [ - "src/lib.cairo", - "Scarb.toml" + "src/lib.cairo" ], "test": [ "tests/custom_set.cairo" ], "example": [ ".meta/example.cairo" + ], + "invalidator": [ + "Scarb.toml" ] }, "blurb": "Create a custom set type." diff --git a/exercises/practice/custom-set/.meta/example.cairo b/exercises/practice/custom-set/.meta/example.cairo index 612658fe..2e13009e 100644 --- a/exercises/practice/custom-set/.meta/example.cairo +++ b/exercises/practice/custom-set/.meta/example.cairo @@ -122,36 +122,36 @@ pub impl CustomSetImpl< } #[must_use] - fn union(self: @CustomSet, other: @CustomSet) -> CustomSet { + fn difference(self: @CustomSet, other: @CustomSet) -> CustomSet { let mut collection: Array = array![]; let mut i = 0; while let Option::Some(value) = self .collection .get(i) { - collection.append(*value.unbox()); - i += 1; - }; - let mut i = 0; - while let Option::Some(value) = other - .collection - .get(i) { - collection.append(*value.unbox()); + let unboxed = value.unbox(); + if !other.contains(unboxed) { + collection.append(*unboxed); + } i += 1; }; CustomSetImpl::::new(@collection) } #[must_use] - fn difference(self: @CustomSet, other: @CustomSet) -> CustomSet { + fn union(self: @CustomSet, other: @CustomSet) -> CustomSet { let mut collection: Array = array![]; let mut i = 0; while let Option::Some(value) = self .collection .get(i) { - let unboxed = value.unbox(); - if !other.contains(unboxed) { - collection.append(*unboxed); - } + collection.append(*value.unbox()); + i += 1; + }; + let mut i = 0; + while let Option::Some(value) = other + .collection + .get(i) { + collection.append(*value.unbox()); i += 1; }; CustomSetImpl::::new(@collection) diff --git a/exercises/practice/custom-set/src/lib.cairo b/exercises/practice/custom-set/src/lib.cairo index 6a45a622..d3553a2b 100644 --- a/exercises/practice/custom-set/src/lib.cairo +++ b/exercises/practice/custom-set/src/lib.cairo @@ -5,11 +5,13 @@ impl CustomSetEq< T, +Copy, +Drop, +PartialEq, +core::fmt::Display > of PartialEq> { fn eq(lhs: @CustomSet, rhs: @CustomSet) -> bool { - panic!() + // determine whether the two CustomSets are equal + panic!("implement `eq`") } fn ne(lhs: @CustomSet, rhs: @CustomSet) -> bool { - panic!() + // determine whether the two CustomSets are NOT equal + panic!("implement `ne`") } } @@ -18,41 +20,52 @@ pub impl CustomSetImpl< T, +Copy, +Drop, +core::fmt::Display, +PartialEq > of CustomSetTrait { fn new(input: @Array) -> CustomSet { - panic!() + // construct a new CustomSet struct + panic!("implement `new`") } fn add(ref self: CustomSet, element: T) { - panic!(); + // add {element} to the CustomSet + panic!("implement `add`") } fn contains(self: @CustomSet, element: @T) -> bool { - panic!() + // determine whether the CustomSet contains {element} + panic!("implement `contains`") } fn is_subset(self: @CustomSet, other: @CustomSet) -> bool { - panic!() + // determine whether {self} is a subset of {other} + panic!("implement `is_subset`") } fn is_empty(self: @CustomSet) -> bool { - panic!() + // determine whether {self} is empty + panic!("implement `is_empty`") } fn is_disjoint(self: @CustomSet, other: @CustomSet) -> bool { - panic!() + // determine whether {self} and {other} have no elements in common + panic!("implement `is_disjoint`") } #[must_use] fn intersection(self: @CustomSet, other: @CustomSet) -> CustomSet { - panic!() + // construct a CustomSet that contains only those elements from {self} that + // are also contained in {other} + panic!("implement `intersection`") } #[must_use] fn difference(self: @CustomSet, other: @CustomSet) -> CustomSet { - panic!() + // construct a CustomSet that contains only those elements from {self} that + // are NOT contained in {other} + panic!("implement `difference`") } #[must_use] fn union(self: @CustomSet, other: @CustomSet) -> CustomSet { - panic!() + // construct a CustomSet that contains all of the elements from both {self} AND {other} + panic!("implement `union`") } } diff --git a/exercises/practice/dominoes/.meta/config.json b/exercises/practice/dominoes/.meta/config.json index 659f928e..e97b044a 100644 --- a/exercises/practice/dominoes/.meta/config.json +++ b/exercises/practice/dominoes/.meta/config.json @@ -4,14 +4,16 @@ ], "files": { "solution": [ - "src/lib.cairo", - "Scarb.toml" + "src/lib.cairo" ], "test": [ "tests/dominoes.cairo" ], "example": [ ".meta/example.cairo" + ], + "invalidator": [ + "Scarb.toml" ] }, "blurb": "Make a chain of dominoes." diff --git a/exercises/practice/dominoes/src/lib.cairo b/exercises/practice/dominoes/src/lib.cairo index 9f8a1612..f97bae22 100644 --- a/exercises/practice/dominoes/src/lib.cairo +++ b/exercises/practice/dominoes/src/lib.cairo @@ -1,7 +1,6 @@ pub type Domino = (u8, u8); pub fn chain(dominoes: @Array) -> Option> { - panic!( - "From the given dominoes '{dominoes:?}' construct a proper dominoes chain or return Option::None if it is not possible." - ) + // from the given dominoes '{dominoes:?}' construct a proper dominoes chain or return Option::None if it is not possible + panic!("implement `chain`") } diff --git a/exercises/practice/hello-world/.meta/config.json b/exercises/practice/hello-world/.meta/config.json index 3a9f5392..4aeb7551 100644 --- a/exercises/practice/hello-world/.meta/config.json +++ b/exercises/practice/hello-world/.meta/config.json @@ -4,14 +4,16 @@ ], "files": { "solution": [ - "src/lib.cairo", - "Scarb.toml" + "src/lib.cairo" ], "test": [ "tests/hello_world.cairo" ], "example": [ ".meta/example.cairo" + ], + "invalidator": [ + "Scarb.toml" ] }, "blurb": "Exercism's classic introductory exercise. Just say \"Hello, World!\".", diff --git a/exercises/practice/hello-world/.meta/example.cairo b/exercises/practice/hello-world/.meta/example.cairo index 1a2cfb43..9b00e2c3 100644 --- a/exercises/practice/hello-world/.meta/example.cairo +++ b/exercises/practice/hello-world/.meta/example.cairo @@ -1,4 +1,3 @@ -// felt252, a.k.a. "field type", represents a specific type of integer, which can be represented as a string that's limited to 31 characters pub fn hello() -> felt252 { 'Hello, World!' } diff --git a/exercises/practice/hello-world/src/lib.cairo b/exercises/practice/hello-world/src/lib.cairo index 268ae419..227a90c4 100644 --- a/exercises/practice/hello-world/src/lib.cairo +++ b/exercises/practice/hello-world/src/lib.cairo @@ -1,4 +1,3 @@ -// felt252, a.k.a. "field type", represents a specific type of integer, which can be represented as a string that's limited to 31 characters pub fn hello() -> felt252 { 'Goodbye, Mars!' } diff --git a/exercises/practice/largest-series-product/.meta/config.json b/exercises/practice/largest-series-product/.meta/config.json index 6367d969..acef6692 100644 --- a/exercises/practice/largest-series-product/.meta/config.json +++ b/exercises/practice/largest-series-product/.meta/config.json @@ -4,14 +4,16 @@ ], "files": { "solution": [ - "src/lib.cairo", - "Scarb.toml" + "src/lib.cairo" ], "test": [ "tests/largest_series_product.cairo" ], "example": [ ".meta/example.cairo" + ], + "invalidator": [ + "Scarb.toml" ] }, "blurb": "Given a string of digits, calculate the largest product for a contiguous substring of digits of length n.", diff --git a/exercises/practice/largest-series-product/src/lib.cairo b/exercises/practice/largest-series-product/src/lib.cairo index f40ac688..19997154 100644 --- a/exercises/practice/largest-series-product/src/lib.cairo +++ b/exercises/practice/largest-series-product/src/lib.cairo @@ -6,5 +6,5 @@ pub enum Error { } pub fn lsp(input: @ByteArray, span: i32) -> Result { - panic!("implement the 'lsp' function") + panic!("implement `lsp`") } diff --git a/exercises/practice/leap/.meta/config.json b/exercises/practice/leap/.meta/config.json index f8e3ca4d..089c656b 100644 --- a/exercises/practice/leap/.meta/config.json +++ b/exercises/practice/leap/.meta/config.json @@ -4,14 +4,16 @@ ], "files": { "solution": [ - "src/lib.cairo", - "Scarb.toml" + "src/lib.cairo" ], "test": [ "tests/leap.cairo" ], "example": [ ".meta/example.cairo" + ], + "invalidator": [ + "Scarb.toml" ] }, "blurb": "Determine whether a given year is a leap year.", diff --git a/exercises/practice/leap/src/lib.cairo b/exercises/practice/leap/src/lib.cairo index 5993fb97..30e41ab7 100644 --- a/exercises/practice/leap/src/lib.cairo +++ b/exercises/practice/leap/src/lib.cairo @@ -1,3 +1,3 @@ pub fn is_leap_year(year: u64) -> bool { - panic!("true if {year} is a leap year") + panic!("implement `is_leap_year`") } diff --git a/exercises/practice/linked-list/.meta/config.json b/exercises/practice/linked-list/.meta/config.json index 8d95e7da..e5cbc838 100644 --- a/exercises/practice/linked-list/.meta/config.json +++ b/exercises/practice/linked-list/.meta/config.json @@ -4,14 +4,16 @@ ], "files": { "solution": [ - "src/lib.cairo", - "Scarb.toml" + "src/lib.cairo" ], "test": [ "tests/linked_list.cairo" ], "example": [ ".meta/example.cairo" + ], + "invalidator": [ + "Scarb.toml" ] }, "blurb": "Implement a doubly linked list.", diff --git a/exercises/practice/linked-list/.meta/example.cairo b/exercises/practice/linked-list/.meta/example.cairo index 7d81b079..e8125dec 100644 --- a/exercises/practice/linked-list/.meta/example.cairo +++ b/exercises/practice/linked-list/.meta/example.cairo @@ -16,7 +16,7 @@ impl DestructDoublyLinkedList, +Felt252DictValue> of Destruct { - data: T, + station: T, next: Index, previous: Index } @@ -35,10 +35,10 @@ pub impl DoublyLinkedListImpl< *self.len } - fn push(ref self: DoublyLinkedList, data: T) { + fn push(ref self: DoublyLinkedList, station: T) { match self.tail { Option::None => { - let node = NullableTrait::new(NodeTrait::new(data, Option::None, Option::None)); + let node = NullableTrait::new(NodeTrait::new(station, Option::None, Option::None)); self.dict.insert(self.next_index, node); self.tail = Option::Some(self.next_index); self.head = self.tail; @@ -46,7 +46,7 @@ pub impl DoublyLinkedListImpl< self.next_index += 1; }, Option::Some(tail) => { - let node = NullableTrait::new(NodeTrait::new(data, self.tail, Option::None)); + let node = NullableTrait::new(NodeTrait::new(station, self.tail, Option::None)); self.dict.insert(self.next_index, node); let old_tail = self.dict.get(tail).deref(); let updated_old_tail = Node { next: Option::Some(self.next_index), ..old_tail }; @@ -62,12 +62,12 @@ pub impl DoublyLinkedListImpl< match self.len { 0 => Option::None, 1 => { - let data = self.dict.get(self.head.unwrap()).deref().data; + let station = self.dict.get(self.head.unwrap()).deref().station; self.dict.insert(self.head.unwrap(), Default::default()); self.head = Option::None; self.tail = Option::None; self.len -= 1; - Option::Some(data) + Option::Some(station) }, _ => { // pop tail @@ -80,7 +80,7 @@ pub impl DoublyLinkedListImpl< let new_tail = Node { next: Option::None, ..new_tail }; self.dict.insert(self.tail.unwrap(), NullableTrait::new(new_tail)); - Option::Some(popped_tail.data) + Option::Some(popped_tail.station) } } } @@ -89,12 +89,12 @@ pub impl DoublyLinkedListImpl< match self.len { 0 => Option::None, 1 => { - let data = self.dict.get(self.head.unwrap()).deref().data; + let station = self.dict.get(self.head.unwrap()).deref().station; self.dict.insert(self.head.unwrap(), Default::default()); self.head = Option::None; self.tail = Option::None; self.len -= 1; - Option::Some(data) + Option::Some(station) }, _ => { // pop head @@ -107,15 +107,15 @@ pub impl DoublyLinkedListImpl< let new_head = Node { previous: Option::None, ..new_head }; self.dict.insert(self.head.unwrap(), NullableTrait::new(new_head)); - Option::Some(shifted_head.data) + Option::Some(shifted_head.station) } } } - fn unshift(ref self: DoublyLinkedList, data: T) { + fn unshift(ref self: DoublyLinkedList, station: T) { match self.head { Option::None => { - let node = NullableTrait::new(NodeTrait::new(data, Option::None, Option::None)); + let node = NullableTrait::new(NodeTrait::new(station, Option::None, Option::None)); self.dict.insert(self.next_index, node); self.head = Option::Some(self.next_index); self.tail = self.head; @@ -123,7 +123,7 @@ pub impl DoublyLinkedListImpl< self.next_index += 1; }, Option::Some(head) => { - let node = NullableTrait::new(NodeTrait::new(data, Option::None, self.head)); + let node = NullableTrait::new(NodeTrait::new(station, Option::None, self.head)); self.dict.insert(self.next_index, node); let old_head = self.dict.get(head).deref(); let updated_old_head = Node { previous: Option::Some(self.next_index), ..old_head }; @@ -135,7 +135,7 @@ pub impl DoublyLinkedListImpl< } } - fn delete(ref self: DoublyLinkedList, data: T) { + fn delete(ref self: DoublyLinkedList, station: T) { if self.head.is_none() { return; } @@ -145,7 +145,7 @@ pub impl DoublyLinkedListImpl< to_remove { let node = self.dict.get(to_remove_index).deref(); - if node.data != data { + if node.station != station { to_remove = node.next; continue; } @@ -176,7 +176,7 @@ pub impl DoublyLinkedListImpl< #[generate_trait] impl NodeImpl of NodeTrait { - fn new(data: T, previous: Index, next: Index) -> Node { - Node { data, previous, next } + fn new(station: T, previous: Index, next: Index) -> Node { + Node { station, previous, next } } } diff --git a/exercises/practice/linked-list/src/lib.cairo b/exercises/practice/linked-list/src/lib.cairo index 1eea38f5..944c9a03 100644 --- a/exercises/practice/linked-list/src/lib.cairo +++ b/exercises/practice/linked-list/src/lib.cairo @@ -4,30 +4,37 @@ struct DoublyLinkedList {} #[generate_trait] pub impl DoublyLinkedListImpl> of DoublyLinkedListTrait { fn new() -> DoublyLinkedList { - panic!("implement 'new'") + // constructs a new DoublyLinkedList struct + panic!("implement `new`") } fn len(self: @DoublyLinkedList) -> usize { - panic!("implement 'len'") + // returns the list's length + panic!("implement `len`") } - fn push(ref self: DoublyLinkedList, data: T) { - panic!("implement 'push'") + fn push(ref self: DoublyLinkedList, station: T) { + // adds a new element to the end of the list + panic!("implement `push`") } fn pop(ref self: DoublyLinkedList) -> Option { - panic!("implement 'pop'") + // removes the last element in the list and returns it + panic!("implement `pop`") } fn shift(ref self: DoublyLinkedList) -> Option { - panic!("implement 'shift'") + // removes the first element in the list and returns it + panic!("implement `shift`") } - fn unshift(ref self: DoublyLinkedList, data: T) { - panic!("implement 'unshift'") + fn unshift(ref self: DoublyLinkedList, station: T) { + // adds a new element to the beginning of the list + panic!("implement `unshift`") } - fn delete(ref self: DoublyLinkedList, data: T) { - panic!("implement 'delete'") + fn delete(ref self: DoublyLinkedList, station: T) { + // removes the first occurrence of the specified station + panic!("implement `delete`") } } diff --git a/exercises/practice/lucians-luscious-lasagna/.meta/config.json b/exercises/practice/lucians-luscious-lasagna/.meta/config.json index cd731941..2e27778d 100644 --- a/exercises/practice/lucians-luscious-lasagna/.meta/config.json +++ b/exercises/practice/lucians-luscious-lasagna/.meta/config.json @@ -4,14 +4,16 @@ ], "files": { "solution": [ - "src/lib.cairo", - "Scarb.toml" + "src/lib.cairo" ], "test": [ "tests/lucians_luscious_lasagna.cairo" ], "example": [ ".meta/example.cairo" + ], + "invalidator": [ + "Scarb.toml" ] }, "icon": "lasagna", diff --git a/exercises/practice/lucians-luscious-lasagna/src/lib.cairo b/exercises/practice/lucians-luscious-lasagna/src/lib.cairo index 3e04a227..abdc6582 100644 --- a/exercises/practice/lucians-luscious-lasagna/src/lib.cairo +++ b/exercises/practice/lucians-luscious-lasagna/src/lib.cairo @@ -1,19 +1,19 @@ pub fn expected_minutes_in_oven() -> u32 { - panic!("return expected minutes in the oven") + // return expected minutes in the oven + panic!("implement `expected_minutes_in_oven`") } pub fn remaining_minutes_in_oven(actual_minutes_in_oven: u32) -> u32 { - panic!( - "calculate remaining minutes in oven given actual minutes in oven: {actual_minutes_in_oven}" - ) + // calculate remaining minutes in oven given actual minutes in oven: {actual_minutes_in_oven} + panic!("implement `remaining_minutes_in_oven`") } pub fn preparation_time_in_minutes(number_of_layers: u32) -> u32 { - panic!("calculate preparation time in minutes for number of layers: {number_of_layers}") + // calculate preparation time in minutes for number of layers: {number_of_layers} + panic!("implement `preparation_time_in_minutes`") } pub fn elapsed_time_in_minutes(number_of_layers: u32, actual_minutes_in_oven: u32) -> u32 { - panic!( - "calculate elapsed time in minutes for number of layers {number_of_layers} and actual minutes in oven {actual_minutes_in_oven}" - ) + // calculate elapsed time in minutes for number of layers {number_of_layers} and actual minutes in oven {actual_minutes_in_oven} + panic!("implement `elapsed_time_in_minutes`") } diff --git a/exercises/practice/protein-translation/.meta/config.json b/exercises/practice/protein-translation/.meta/config.json index 930d238e..03d124f2 100644 --- a/exercises/practice/protein-translation/.meta/config.json +++ b/exercises/practice/protein-translation/.meta/config.json @@ -4,14 +4,16 @@ ], "files": { "solution": [ - "src/lib.cairo", - "Scarb.toml" + "src/lib.cairo" ], "test": [ "tests/protein_translation.cairo" ], "example": [ ".meta/example.cairo" + ], + "invalidator": [ + "Scarb.toml" ] }, "blurb": "Translate RNA sequences into proteins.", diff --git a/exercises/practice/protein-translation/.meta/example.cairo b/exercises/practice/protein-translation/.meta/example.cairo index 51aa5154..f7c51d1f 100644 --- a/exercises/practice/protein-translation/.meta/example.cairo +++ b/exercises/practice/protein-translation/.meta/example.cairo @@ -66,9 +66,7 @@ pub impl CodonsInfoImpl of CodonsInfoTrait { const TWO_POW_8: u32 = 0x100; const TWO_POW_16: u32 = 0x10000; -/// This is a helper trait that you may find useful. -/// -/// It extracts a codon from a given ByteArray from index `from`. +/// Extracts a codon from a given ByteArray from index `from`. /// Needs to extract 3 ByteArray characters and convert them to the appropriate /// felt252 value. It does this by taking the characters' byte value and moving /// their bits to the left depending on their position in the codon. diff --git a/exercises/practice/protein-translation/src/lib.cairo b/exercises/practice/protein-translation/src/lib.cairo index 79469dd2..e434030e 100644 --- a/exercises/practice/protein-translation/src/lib.cairo +++ b/exercises/practice/protein-translation/src/lib.cairo @@ -2,60 +2,19 @@ struct CodonsInfo {} pub fn parse(pairs: Array<(felt252, ByteArray)>) -> CodonsInfo { - panic!() + // constructs a new CodonsInfo struct + panic!("implement `parse`") } #[generate_trait] pub impl CodonsInfoImpl of CodonsInfoTrait { fn name_for(ref self: CodonsInfo, codon: felt252) -> ByteArray { - panic!() + // return name for {codon} + panic!("implement `name_for`") } fn of_rna(ref self: CodonsInfo, strand: ByteArray) -> Option> { - panic!() - } -} - -const TWO_POW_8: u32 = 0x100; -const TWO_POW_16: u32 = 0x10000; - -/// This is a helper trait that you may find useful. -/// -/// It extracts a codon from a given ByteArray from index `from`. -/// Needs to extract 3 ByteArray characters and convert them to the appropriate -/// felt252 value. It does this by taking the characters' byte value and moving -/// their bits to the left depending on their position in the codon. -/// -/// Example: -/// 1. Method call: "AUG".codon_chunk(0) -/// 2. Chars and their byte (hex) values: -/// - "A" = 0x41 -/// - "U" = 0x55 -/// - "G" = 0x47 -/// 3. "A" is the leftmost character, so we "move" it 2 bytes to the left by -/// multiplying it by 2^16 (hex value: 0x10000) -/// 4. "U" is the middle character, so we "move" it 1 byte to the left by -/// multiplying it by 2^8 (hex value: 0x100) -/// 5. "G" is the rightmost character, so we leave it in place -/// 6. Codon = "A" * 2^16 + "U" * 2^8 + "G" -/// = 0x41 * 0x10000 + 0x55 * 0x100 * 0x47 -/// = 0x415547 -/// 7. (41)(55)(47) are hex values for (A)(U)(G) -/// -/// Returns: -/// - Option::Some(codon) -> if the extraction was successful -/// - Option::None -> if the ByteArray was too short from the given index -#[generate_trait] -impl CodonChunk of CodonChunkTrait { - fn codon_chunk(self: @ByteArray, from: usize) -> Option { - if let Option::Some(char) = self.at(from + 2) { - let codon = char.into() - + self[from - + 1].into() * TWO_POW_8 - + self[from].into() * TWO_POW_16; - Option::Some(codon.into()) - } else { - Option::None - } + // return the array of codon names that correspond to the given strand of RNA (represented as a string of codons) + panic!("implement `of_rna`") } } diff --git a/exercises/practice/rational-numbers/.meta/config.json b/exercises/practice/rational-numbers/.meta/config.json index 29a2d88b..66df43dd 100644 --- a/exercises/practice/rational-numbers/.meta/config.json +++ b/exercises/practice/rational-numbers/.meta/config.json @@ -4,14 +4,16 @@ ], "files": { "solution": [ - "src/lib.cairo", - "Scarb.toml" + "src/lib.cairo" ], "test": [ "tests/rational_numbers.cairo" ], "example": [ ".meta/example.cairo" + ], + "invalidator": [ + "Scarb.toml" ] }, "blurb": "Implement rational numbers.", diff --git a/exercises/practice/rational-numbers/src/lib.cairo b/exercises/practice/rational-numbers/src/lib.cairo index 67e1f443..bdba9639 100644 --- a/exercises/practice/rational-numbers/src/lib.cairo +++ b/exercises/practice/rational-numbers/src/lib.cairo @@ -6,65 +6,77 @@ struct Rational {} #[generate_trait] pub impl RationalImpl of RationalTrait { fn new(numer: i128, denom: i128) -> Rational { - panic!() + // construct a new Rational struct + panic!("implement `new`") } } impl RationalPartialEq of PartialEq { fn eq(lhs: @Rational, rhs: @Rational) -> bool { - panic!() + // determine whether the two Rational numbers are equal + panic!("implement `eq`") } fn ne(lhs: @Rational, rhs: @Rational) -> bool { - panic!() + // determine whether the two Rational numbers are NOT equal + panic!("implement `ne`") } } impl RationalNeg of Neg { fn neg(a: Rational) -> Rational { - panic!() + // return the negative value of the Rational number {a} + panic!("implement `neg`") } } impl RationalAdd of Add { fn add(lhs: Rational, rhs: Rational) -> Rational { - panic!() + // return the sum of {lhs} and {rhs} + panic!("implement `add`") } } impl RationalSub of Sub { fn sub(lhs: Rational, rhs: Rational) -> Rational { - panic!() + // return the difference of {lhs} and {rhs} + panic!("implement `sub`") } } impl RationalMul of Mul { fn mul(lhs: Rational, rhs: Rational) -> Rational { - panic!() + // return the product of {lhs} and {rhs} + panic!("implement `mul`") } } impl RationalDiv of Div { fn div(lhs: Rational, rhs: Rational) -> Rational { - panic!() + // return the quotient of {lhs} and {rhs} + panic!("implement `div`") } } #[generate_trait] pub impl RationalAbs of RationalAbsTrait { fn abs(self: @Rational) -> Rational { - panic!() + // return the absolute value of the given Rational number + panic!("implement `abs`") } } #[generate_trait] pub impl RationalPow of RationalPowTrait { fn pow(self: @Rational, power: i128) -> Rational { - panic!() + // return a Rational number that is the result of raising {self} to the power of {power} + panic!("implement `pow`") } fn rpow(self: @u128, power: Rational) -> u128 { - panic!() + // return an integer that is the result of raising the integer {self} to the power of + // a Rational number {power} + panic!("implement `rpow`") } } diff --git a/exercises/practice/robot-simulator/.meta/config.json b/exercises/practice/robot-simulator/.meta/config.json index ce425c94..a962b2b3 100644 --- a/exercises/practice/robot-simulator/.meta/config.json +++ b/exercises/practice/robot-simulator/.meta/config.json @@ -4,14 +4,16 @@ ], "files": { "solution": [ - "src/lib.cairo", - "Scarb.toml" + "src/lib.cairo" ], "test": [ "tests/robot_simulator.cairo" ], "example": [ ".meta/example.cairo" + ], + "invalidator": [ + "Scarb.toml" ] }, "blurb": "Write a robot simulator.", diff --git a/exercises/practice/robot-simulator/src/lib.cairo b/exercises/practice/robot-simulator/src/lib.cairo index 184f1121..a1cee31d 100644 --- a/exercises/practice/robot-simulator/src/lib.cairo +++ b/exercises/practice/robot-simulator/src/lib.cairo @@ -1,6 +1,3 @@ -// The code below is a stub. Just enough to satisfy the compiler. -// In order to pass the tests you can add-to or change any of this code. - #[derive(Drop, PartialEq, Debug)] pub enum Direction { North, @@ -15,34 +12,41 @@ struct Robot {} #[generate_trait] pub impl RobotImpl of RobotTrait { fn new(x: i32, y: i32, d: Direction) -> Robot { - panic!("Create a robot at (x, y) facing {d:?}") + // construct a Robot at (x, y) facing {d:?} + panic!("implement `new`") } #[must_use] fn turn_right(self: Robot) -> Robot { - panic!() + // update the direction of the Robot to the right + panic!("implement `turn_right`") } #[must_use] fn turn_left(self: Robot) -> Robot { - panic!() + // update the direction of the Robot to the left + panic!("implement `turn_left`") } #[must_use] fn advance(self: Robot) -> Robot { - panic!() + // move the Robot by 1 along the 'x' or 'y' axis, depending on its direction + panic!("implement `advance`") } #[must_use] fn instructions(self: Robot, instructions: ByteArray) -> Robot { - panic!("Follow the given sequence of instructions: {instructions}") + // follow the given sequence of instructions: {instructions} + panic!("implement `instructions`") } fn position(self: @Robot) -> (i32, i32) { - panic!() + // return Robot's current (x, y) position + panic!("implement `position`") } fn direction(self: @Robot) -> @Direction { - panic!() + // return Robot's current direction + panic!("implement `direction`") } } diff --git a/exercises/practice/roman-numerals/.meta/config.json b/exercises/practice/roman-numerals/.meta/config.json index 2fdbdda8..b8a2d6e2 100644 --- a/exercises/practice/roman-numerals/.meta/config.json +++ b/exercises/practice/roman-numerals/.meta/config.json @@ -4,14 +4,16 @@ ], "files": { "solution": [ - "src/lib.cairo", - "Scarb.toml" + "src/lib.cairo" ], "test": [ "tests/roman_numerals.cairo" ], "example": [ ".meta/example.cairo" + ], + "invalidator": [ + "Scarb.toml" ] }, "blurb": "Convert modern Arabic numbers into Roman numerals.", diff --git a/exercises/practice/roman-numerals/src/lib.cairo b/exercises/practice/roman-numerals/src/lib.cairo index 20ccae12..41554a04 100644 --- a/exercises/practice/roman-numerals/src/lib.cairo +++ b/exercises/practice/roman-numerals/src/lib.cairo @@ -6,12 +6,14 @@ pub struct Roman {} impl U32IntoRoman of Into { #[must_use] fn into(self: u32) -> Roman { - panic!() + // convert the integer into a Roman number + panic!("implement `into`") } } impl RomanDisplay of Display { fn fmt(self: @Roman, ref f: Formatter) -> Result<(), Error> { - panic!() + // define how the Roman number should be converted to a string + panic!("implement `fmt`") } } diff --git a/exercises/practice/scrabble-score/.meta/config.json b/exercises/practice/scrabble-score/.meta/config.json index 5a52431c..16caf0f0 100644 --- a/exercises/practice/scrabble-score/.meta/config.json +++ b/exercises/practice/scrabble-score/.meta/config.json @@ -4,14 +4,16 @@ ], "files": { "solution": [ - "src/lib.cairo", - "Scarb.toml" + "src/lib.cairo" ], "test": [ "tests/scrabble_score.cairo" ], "example": [ ".meta/example.cairo" + ], + "invalidator": [ + "Scarb.toml" ] }, "blurb": "Given a word, compute the Scrabble score for that word.", diff --git a/exercises/practice/scrabble-score/src/lib.cairo b/exercises/practice/scrabble-score/src/lib.cairo index 24878e6a..abf3bc3b 100644 --- a/exercises/practice/scrabble-score/src/lib.cairo +++ b/exercises/practice/scrabble-score/src/lib.cairo @@ -1,3 +1,4 @@ pub fn score(word: ByteArray) -> u16 { - panic!("Score {word} in Scrabble.") + // return the Scrable score for: '{word}' + panic!("implement `score`") } diff --git a/exercises/practice/semi-structured-logs/.meta/config.json b/exercises/practice/semi-structured-logs/.meta/config.json index c7389a42..2291fb74 100644 --- a/exercises/practice/semi-structured-logs/.meta/config.json +++ b/exercises/practice/semi-structured-logs/.meta/config.json @@ -4,14 +4,16 @@ ], "files": { "solution": [ - "src/lib.cairo", - "Scarb.toml" + "src/lib.cairo" ], "test": [ "tests/semi_structured_logs.cairo" ], "example": [ ".meta/example.cairo" + ], + "invalidator": [ + "Scarb.toml" ] }, "blurb": "Learn enums while building a logging utility." diff --git a/exercises/practice/semi-structured-logs/src/lib.cairo b/exercises/practice/semi-structured-logs/src/lib.cairo index 9b630b0d..a07133d4 100644 --- a/exercises/practice/semi-structured-logs/src/lib.cairo +++ b/exercises/practice/semi-structured-logs/src/lib.cairo @@ -9,17 +9,21 @@ pub enum LogLevel { /// primary function for emitting logs pub fn log(level: LogLevel, message: ByteArray) -> ByteArray { - panic!("return a message for the given log level") + // return a message for the given log level + panic!("implement `log`") } pub fn info(message: ByteArray) -> ByteArray { - panic!("return a message for info log level") + // return a message for info log level + panic!("implement `info`") } pub fn warn(message: ByteArray) -> ByteArray { - panic!("return a message for warn log level") + // return a message for warn log level + panic!("implement `warn`") } pub fn error(message: ByteArray) -> ByteArray { - panic!("return a message for error log level") + // return a message for error log level + panic!("implement `error`") } diff --git a/exercises/practice/simple-linked-list/.meta/config.json b/exercises/practice/simple-linked-list/.meta/config.json index 49bb1d83..2a521ea6 100644 --- a/exercises/practice/simple-linked-list/.meta/config.json +++ b/exercises/practice/simple-linked-list/.meta/config.json @@ -4,14 +4,16 @@ ], "files": { "solution": [ - "src/lib.cairo", - "Scarb.toml" + "src/lib.cairo" ], "test": [ "tests/simple_linked_list.cairo" ], "example": [ ".meta/example.cairo" + ], + "invalidator": [ + "Scarb.toml" ] }, "blurb": "Write a simple linked list implementation that uses Elements and a List.", diff --git a/exercises/practice/simple-linked-list/src/lib.cairo b/exercises/practice/simple-linked-list/src/lib.cairo index fcc31c36..903098a0 100644 --- a/exercises/practice/simple-linked-list/src/lib.cairo +++ b/exercises/practice/simple-linked-list/src/lib.cairo @@ -4,45 +4,54 @@ pub struct SimpleLinkedList {} #[generate_trait] pub impl SimpleLinkedListImpl, +Copy> of SimpleLinkedListTrait { fn new() -> SimpleLinkedList { - panic!() + // construct a new SimpleLinkedList struct + panic!("implement `new`") } fn is_empty(self: @SimpleLinkedList) -> bool { - panic!() + // determine whether the list is empty + panic!("implement `is_empty`") } fn len(self: @SimpleLinkedList) -> usize { - panic!() + // return the list's length + panic!("implement `len`") } fn push(ref self: SimpleLinkedList, element: T) { - panic!() + // add a new element to the start of the list + panic!("implement `push`") } fn pop(ref self: SimpleLinkedList) -> Option { - panic!() + // remove the first element of the list and return it + panic!("implement `pop`") } fn peek(self: @SimpleLinkedList) -> Option<@T> { - panic!() + // return the first element of the list + panic!("implement `peek`") } #[must_use] fn rev(self: SimpleLinkedList) -> SimpleLinkedList { - panic!() + // return the reversed list + panic!("implement `rev`") } } impl ArrayIntoSimpleLinkedList, +Copy> of Into, SimpleLinkedList> { #[must_use] fn into(self: Array) -> SimpleLinkedList { - panic!() + // construct a list from the given array + panic!("implement `into`") } } impl SimpleLinkedListIntoArray, +Copy> of Into, Array> { #[must_use] fn into(self: SimpleLinkedList) -> Array { - panic!() + // construct an array from the given list + panic!("implement `into`") } } diff --git a/exercises/practice/sublist/.meta/config.json b/exercises/practice/sublist/.meta/config.json index c82aa4bc..a0fb36b7 100644 --- a/exercises/practice/sublist/.meta/config.json +++ b/exercises/practice/sublist/.meta/config.json @@ -4,14 +4,16 @@ ], "files": { "solution": [ - "src/lib.cairo", - "Scarb.toml" + "src/lib.cairo" ], "test": [ "tests/sublist.cairo" ], "example": [ ".meta/example.cairo" + ], + "invalidator": [ + "Scarb.toml" ] }, "blurb": "Write a function to determine if a list is a sublist of another list." diff --git a/exercises/practice/sublist/src/lib.cairo b/exercises/practice/sublist/src/lib.cairo index 999ebbb2..c609a7fc 100644 --- a/exercises/practice/sublist/src/lib.cairo +++ b/exercises/practice/sublist/src/lib.cairo @@ -7,5 +7,5 @@ pub enum Comparison { } pub fn sublist>(a: @Array, b: @Array) -> Comparison { - panic!() + panic!("implement `sublist`") }