diff --git a/concepts/booleans/.meta/config.json b/concepts/booleans/.meta/config.json new file mode 100644 index 00000000..52914445 --- /dev/null +++ b/concepts/booleans/.meta/config.json @@ -0,0 +1,7 @@ +{ + "blurb": "", + "authors": [ + "misicnenad" + ], + "contributors": [] +} diff --git a/concepts/booleans/about.md b/concepts/booleans/about.md new file mode 100644 index 00000000..60fa421d --- /dev/null +++ b/concepts/booleans/about.md @@ -0,0 +1 @@ +# Boolean Types diff --git a/concepts/booleans/introduction.md b/concepts/booleans/introduction.md new file mode 100644 index 00000000..e10b99d0 --- /dev/null +++ b/concepts/booleans/introduction.md @@ -0,0 +1 @@ +# Introduction diff --git a/concepts/booleans/links.json b/concepts/booleans/links.json new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/concepts/booleans/links.json @@ -0,0 +1 @@ +[] diff --git a/concepts/integers/.meta/config.json b/concepts/integers/.meta/config.json new file mode 100644 index 00000000..52914445 --- /dev/null +++ b/concepts/integers/.meta/config.json @@ -0,0 +1,7 @@ +{ + "blurb": "", + "authors": [ + "misicnenad" + ], + "contributors": [] +} diff --git a/concepts/integers/about.md b/concepts/integers/about.md new file mode 100644 index 00000000..56cb1705 --- /dev/null +++ b/concepts/integers/about.md @@ -0,0 +1 @@ +# Integer Types diff --git a/concepts/integers/introduction.md b/concepts/integers/introduction.md new file mode 100644 index 00000000..e10b99d0 --- /dev/null +++ b/concepts/integers/introduction.md @@ -0,0 +1 @@ +# Introduction diff --git a/concepts/integers/links.json b/concepts/integers/links.json new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/concepts/integers/links.json @@ -0,0 +1 @@ +[] diff --git a/concepts/strings/.meta/config.json b/concepts/strings/.meta/config.json index ebb4b627..52914445 100644 --- a/concepts/strings/.meta/config.json +++ b/concepts/strings/.meta/config.json @@ -1,5 +1,5 @@ { - "blurb": "ByteArray is a sequence of ASCII characters longer than 31 characters, written using double quotes", + "blurb": "", "authors": [ "misicnenad" ], diff --git a/concepts/strings/about.md b/concepts/strings/about.md index 2c0923c4..0690082b 100644 --- a/concepts/strings/about.md +++ b/concepts/strings/about.md @@ -1 +1 @@ -# String +# String Types diff --git a/config.json b/config.json index 33a2726b..34720c98 100644 --- a/config.json +++ b/config.json @@ -47,6 +47,19 @@ "topics": [ "test_driven_development" ] + }, + { + "slug": "leap", + "name": "Leap", + "uuid": "9b586e17-928c-42bf-95ed-67539daea9a8", + "practices": [ + "booleans" + ], + "prerequisites": [], + "difficulty": 1, + "topics": [ + "conditionals" + ] } ] }, @@ -55,6 +68,16 @@ "uuid": "4eb800f7-f6c5-4b28-8492-229b6a51829e", "slug": "strings", "name": "Strings" + }, + { + "uuid": "9f7e96c1-a3ab-4ab9-b021-563453b1e664", + "slug": "integers", + "name": "Integers" + }, + { + "uuid": "de254443-42ee-4787-bc1e-3d0d2039c4f5", + "slug": "booleans", + "name": "Booleans" } ], "key_features": [ @@ -62,7 +85,7 @@ "title": "Developer-friendly", "content": "Write Rust-like code and generate proofs for program execution - math isn't a barrier.", "icon": "easy" - }, + }, { "title": "Provable", "content": "Produces provable programs, making it possible to compute trustworthy values on untrusted machines.", diff --git a/exercises/practice/leap/.docs/instructions.md b/exercises/practice/leap/.docs/instructions.md new file mode 100644 index 00000000..b14f8565 --- /dev/null +++ b/exercises/practice/leap/.docs/instructions.md @@ -0,0 +1,3 @@ +# Instructions + +Your task is to determine whether a given year is a leap year. diff --git a/exercises/practice/leap/.docs/introduction.md b/exercises/practice/leap/.docs/introduction.md new file mode 100644 index 00000000..4ffd2da5 --- /dev/null +++ b/exercises/practice/leap/.docs/introduction.md @@ -0,0 +1,16 @@ +# Introduction + +A leap year (in the Gregorian calendar) occurs: + +- In every year that is evenly divisible by 4. +- Unless the year is evenly divisible by 100, in which case it's only a leap year if the year is also evenly divisible by 400. + +Some examples: + +- 1997 was not a leap year as it's not divisible by 4. +- 1900 was not a leap year as it's not divisible by 400. +- 2000 was a leap year! + +~~~~exercism/note +For a delightful, four-minute explanation of the whole phenomenon of leap years, check out [this YouTube video](https://www.youtube.com/watch?v=xX96xng7sAE). +~~~~ diff --git a/exercises/practice/leap/.meta/config.json b/exercises/practice/leap/.meta/config.json new file mode 100644 index 00000000..04e82176 --- /dev/null +++ b/exercises/practice/leap/.meta/config.json @@ -0,0 +1,18 @@ +{ + "authors": [], + "files": { + "solution": [ + "src/lib.cairo", + "Scarb.toml" + ], + "test": [ + "src/tests.cairo" + ], + "example": [ + ".meta/example.cairo" + ] + }, + "blurb": "Determine whether a given year is a leap year.", + "source": "CodeRanch Cattle Drive, Assignment 3", + "source_url": "https://coderanch.com/t/718816/Leap" +} diff --git a/exercises/practice/leap/.meta/example.cairo b/exercises/practice/leap/.meta/example.cairo new file mode 100644 index 00000000..380d1e5c --- /dev/null +++ b/exercises/practice/leap/.meta/example.cairo @@ -0,0 +1,7 @@ +fn is_leap_year(year: u64) -> bool { + has_factor(year, 4) && (!has_factor(year, 100) || has_factor(year, 400)) +} + +fn has_factor(year: u64, factor: u64) -> bool { + year % factor == 0 +} diff --git a/exercises/practice/leap/.meta/tests.toml b/exercises/practice/leap/.meta/tests.toml new file mode 100644 index 00000000..ce6ba325 --- /dev/null +++ b/exercises/practice/leap/.meta/tests.toml @@ -0,0 +1,37 @@ +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. + +[6466b30d-519c-438e-935d-388224ab5223] +description = "year not divisible by 4 in common year" + +[ac227e82-ee82-4a09-9eb6-4f84331ffdb0] +description = "year divisible by 2, not divisible by 4 in common year" + +[4fe9b84c-8e65-489e-970b-856d60b8b78e] +description = "year divisible by 4, not divisible by 100 in leap year" + +[7fc6aed7-e63c-48f5-ae05-5fe182f60a5d] +description = "year divisible by 4 and 5 is still a leap year" + +[78a7848f-9667-4192-ae53-87b30c9a02dd] +description = "year divisible by 100, not divisible by 400 in common year" + +[9d70f938-537c-40a6-ba19-f50739ce8bac] +description = "year divisible by 100 but not by 3 is still not a leap year" + +[42ee56ad-d3e6-48f1-8e3f-c84078d916fc] +description = "year divisible by 400 is leap year" + +[57902c77-6fe9-40de-8302-587b5c27121e] +description = "year divisible by 400 but not by 125 is still a leap year" + +[c30331f6-f9f6-4881-ad38-8ca8c12520c1] +description = "year divisible by 200, not divisible by 400 in common year" diff --git a/exercises/practice/leap/Scarb.toml b/exercises/practice/leap/Scarb.toml new file mode 100644 index 00000000..0f2f16bc --- /dev/null +++ b/exercises/practice/leap/Scarb.toml @@ -0,0 +1,4 @@ +[package] +name = "leap" +version = "0.1.0" +edition = "2023_11" diff --git a/exercises/practice/leap/src/lib.cairo b/exercises/practice/leap/src/lib.cairo new file mode 100644 index 00000000..e9e68239 --- /dev/null +++ b/exercises/practice/leap/src/lib.cairo @@ -0,0 +1,6 @@ +fn is_leap_year(year: u64) -> bool { + panic!("true if {year} is a leap year") +} + +#[cfg(test)] +mod tests; diff --git a/exercises/practice/leap/src/tests.cairo b/exercises/practice/leap/src/tests.cairo new file mode 100644 index 00000000..bd36b05e --- /dev/null +++ b/exercises/practice/leap/src/tests.cairo @@ -0,0 +1,46 @@ +use leap::is_leap_year; + +#[test] +fn year_not_divisible_by_4_in_common_year() { + assert!(!is_leap_year(2015)); +} + +#[test] +fn year_divisible_by_2_not_divisible_by_4_in_common_year() { + assert!(!is_leap_year(1970)); +} + +#[test] +fn year_divisible_by_4_not_divisible_by_100_in_leap_year() { + assert!(is_leap_year(1996)); +} + +#[test] +fn year_divisible_by_4_and_5_is_still_a_leap_year() { + assert!(is_leap_year(1960)); +} + +#[test] +fn year_divisible_by_100_not_divisible_by_400_in_common_year() { + assert!(!is_leap_year(2100)); +} + +#[test] +fn year_divisible_by_100_but_not_by_3_is_still_not_a_leap_year() { + assert!(!is_leap_year(1900)); +} + +#[test] +fn year_divisible_by_400_is_leap_year() { + assert!(is_leap_year(2000)); +} + +#[test] +fn year_divisible_by_400_but_not_by_125_is_still_a_leap_year() { + assert!(is_leap_year(2400)); +} + +#[test] +fn year_divisible_by_200_not_divisible_by_400_in_common_year() { + assert!(!is_leap_year(1800)); +}