Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address maintainer feedback #99

Merged
merged 9 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
},
"files": {
"solution": [
"src/lib.cairo",
"Scarb.toml"
Copy link
Contributor Author

@0xNeshi 0xNeshi Jul 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ErikSchierboom should removing Scarb.toml from this array also remove it from the online editor?
Removed it from all the other config.json files.
http://forum.exercism.org/t/need-maintainers-to-test-the-new-cairo-track/12154/10

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@misicnenad Yes, it will remove it from the online editor. What I would suggest you do is to not remove it, but instead put it in the invalidator key. This will ensure that if the Scarb.toml file changes, students will be prompted to update the exercise. An invalidator files are not shown in the online editor. See https://exercism.org/docs/building/tracks/practice-exercises#h-file-meta-config-json

Copy link
Contributor Author

@0xNeshi 0xNeshi Jul 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 160a33a

Let me know if this is the change you expected to see, and I'll merge this

"src/lib.cairo"
],
"test": [
"tests/%{snake_slug}.cairo"
Expand Down Expand Up @@ -84,7 +83,7 @@
},
{
"slug": "lucians-luscious-lasagna",
"name": "Lucians Luscious Lasagna",
"name": "Lucian's Luscious Lasagna",
"uuid": "8302f8de-14d7-45dd-9a65-812bc1ed5464",
"practices": [
"functions"
Expand Down
3 changes: 1 addition & 2 deletions exercises/concept/low-power-embedded-game/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
],
"files": {
"solution": [
"src/lib.cairo",
"Scarb.toml"
"src/lib.cairo"
],
"test": [
"tests/low_power_embedded_game.cairo"
Expand Down
6 changes: 3 additions & 3 deletions exercises/concept/low-power-embedded-game/src/lib.cairo
Original file line number Diff line number Diff line change
@@ -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<T, +Drop<T>, +Copy<T>> of EvensTrait<T> {
fn evens(self: @Array<T>) -> Array<T> {
panic!("implement `fn evens`")
panic!("implement `evens`")
}
}

Expand All @@ -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`")
}
}
3 changes: 1 addition & 2 deletions exercises/practice/allergies/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
],
"files": {
"solution": [
"src/lib.cairo",
"Scarb.toml"
"src/lib.cairo"
],
"test": [
"tests/allergies.cairo"
Expand Down
11 changes: 6 additions & 5 deletions exercises/practice/allergies/src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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<Allergen> {
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`")
}
}
3 changes: 1 addition & 2 deletions exercises/practice/anagram/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
],
"files": {
"solution": [
"src/lib.cairo",
"Scarb.toml"
"src/lib.cairo"
],
"test": [
"tests/anagram.cairo"
Expand Down
6 changes: 3 additions & 3 deletions exercises/practice/anagram/.meta/example.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ impl SetEq of PartialEq<Set> {
}
}

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)
Expand Down
14 changes: 9 additions & 5 deletions exercises/practice/anagram/src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,24 @@ struct Set {}
#[generate_trait]
pub impl SetImpl of SetTrait {
fn new(values: Array<ByteArray>) -> Set {
panic!()
// construct a new Set struct
panic!("implement `new`")
}
}

impl SetEq of PartialEq<Set> {
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`")
}
3 changes: 1 addition & 2 deletions exercises/practice/armstrong-numbers/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
],
"files": {
"solution": [
"src/lib.cairo",
"Scarb.toml"
"src/lib.cairo"
],
"test": [
"tests/armstrong_numbers.cairo"
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/armstrong-numbers/src/lib.cairo
Original file line number Diff line number Diff line change
@@ -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`")
}
3 changes: 1 addition & 2 deletions exercises/practice/beer-song/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
],
"files": {
"solution": [
"src/lib.cairo",
"Scarb.toml"
"src/lib.cairo"
],
"test": [
"tests/beer_song.cairo"
Expand Down
9 changes: 6 additions & 3 deletions exercises/practice/beer-song/src/lib.cairo
Original file line number Diff line number Diff line change
@@ -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`")
}
3 changes: 1 addition & 2 deletions exercises/practice/binary-search/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
],
"files": {
"solution": [
"src/lib.cairo",
"Scarb.toml"
"src/lib.cairo"
],
"test": [
"tests/binary_search.cairo"
Expand Down
6 changes: 3 additions & 3 deletions exercises/practice/binary-search/src/lib.cairo
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub fn find(search_array: @Array<usize>, value: usize) -> Option<usize> {
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`")
}
3 changes: 1 addition & 2 deletions exercises/practice/clock/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
],
"files": {
"solution": [
"src/lib.cairo",
"Scarb.toml"
"src/lib.cairo"
],
"test": [
"tests/clock.cairo"
Expand Down
5 changes: 4 additions & 1 deletion exercises/practice/clock/src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@ struct Clock {

impl ClockDisplay of Display<Clock> {
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`")
}

Expand Down
3 changes: 1 addition & 2 deletions exercises/practice/custom-set/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
],
"files": {
"solution": [
"src/lib.cairo",
"Scarb.toml"
"src/lib.cairo"
],
"test": [
"tests/custom_set.cairo"
Expand Down
28 changes: 14 additions & 14 deletions exercises/practice/custom-set/.meta/example.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -122,36 +122,36 @@ pub impl CustomSetImpl<
}

#[must_use]
fn union(self: @CustomSet<T>, other: @CustomSet<T>) -> CustomSet<T> {
fn difference(self: @CustomSet<T>, other: @CustomSet<T>) -> CustomSet<T> {
let mut collection: Array<T> = 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::<T>::new(@collection)
}

#[must_use]
fn difference(self: @CustomSet<T>, other: @CustomSet<T>) -> CustomSet<T> {
fn union(self: @CustomSet<T>, other: @CustomSet<T>) -> CustomSet<T> {
let mut collection: Array<T> = 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::<T>::new(@collection)
Expand Down
35 changes: 24 additions & 11 deletions exercises/practice/custom-set/src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ impl CustomSetEq<
T, +Copy<T>, +Drop<T>, +PartialEq<T>, +core::fmt::Display<T>
> of PartialEq<CustomSet<T>> {
fn eq(lhs: @CustomSet<T>, rhs: @CustomSet<T>) -> bool {
panic!()
// determine whether the two CustomSets are equal
panic!("implement `eq`")
}

fn ne(lhs: @CustomSet<T>, rhs: @CustomSet<T>) -> bool {
panic!()
// determine whether the two CustomSets are NOT equal
panic!("implement `ne`")
}
}

Expand All @@ -18,41 +20,52 @@ pub impl CustomSetImpl<
T, +Copy<T>, +Drop<T>, +core::fmt::Display<T>, +PartialEq<T>
> of CustomSetTrait<T> {
fn new(input: @Array<T>) -> CustomSet<T> {
panic!()
// construct a new CustomSet struct
panic!("implement `new`")
}

fn add(ref self: CustomSet<T>, element: T) {
panic!();
// add {element} to the CustomSet
panic!("implement `add`")
}

fn contains(self: @CustomSet<T>, element: @T) -> bool {
panic!()
// determine whether the CustomSet contains {element}
panic!("implement `contains`")
}

fn is_subset(self: @CustomSet<T>, other: @CustomSet<T>) -> bool {
panic!()
// determine whether {self} is a subset of {other}
panic!("implement `is_subset`")
}

fn is_empty(self: @CustomSet<T>) -> bool {
panic!()
// determine whether {self} is empty
panic!("implement `is_empty`")
}

fn is_disjoint(self: @CustomSet<T>, other: @CustomSet<T>) -> bool {
panic!()
// determine whether {self} and {other} have no elements in common
panic!("implement `is_disjoint`")
}

#[must_use]
fn intersection(self: @CustomSet<T>, other: @CustomSet<T>) -> CustomSet<T> {
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<T>, other: @CustomSet<T>) -> CustomSet<T> {
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<T>, other: @CustomSet<T>) -> CustomSet<T> {
panic!()
// construct a CustomSet that contains all of the elements from both {self} AND {other}
panic!("implement `union`")
}
}
3 changes: 1 addition & 2 deletions exercises/practice/dominoes/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
],
"files": {
"solution": [
"src/lib.cairo",
"Scarb.toml"
"src/lib.cairo"
],
"test": [
"tests/dominoes.cairo"
Expand Down
5 changes: 2 additions & 3 deletions exercises/practice/dominoes/src/lib.cairo
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
pub type Domino = (u8, u8);

pub fn chain(dominoes: @Array<Domino>) -> Option<Array<Domino>> {
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`")
}
Loading
Loading