diff --git a/.gitignore b/.gitignore index 6a513a06..68ccd3f3 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ .DS_Store bin/configlet bin/configlet.exe +**/target +exercises/*/*/Scarb.lock diff --git a/concepts/strings/.meta/config.json b/concepts/strings/.meta/config.json new file mode 100644 index 00000000..ebb4b627 --- /dev/null +++ b/concepts/strings/.meta/config.json @@ -0,0 +1,7 @@ +{ + "blurb": "ByteArray is a sequence of ASCII characters longer than 31 characters, written using double quotes", + "authors": [ + "misicnenad" + ], + "contributors": [] +} diff --git a/concepts/strings/about.md b/concepts/strings/about.md new file mode 100644 index 00000000..2c0923c4 --- /dev/null +++ b/concepts/strings/about.md @@ -0,0 +1 @@ +# String diff --git a/concepts/strings/introduction.md b/concepts/strings/introduction.md new file mode 100644 index 00000000..d5e1124b --- /dev/null +++ b/concepts/strings/introduction.md @@ -0,0 +1,3 @@ +# Introduction + +In Cairo, there's no native type for strings. Instead, you can use a single `felt252` to store a short string of up to 31 characters, or a `ByteArray` for strings of arbitrary length. Short strings use single quotes and `ByteArray` uses double quotes. All characters must follow the ASCII standard. diff --git a/concepts/strings/links.json b/concepts/strings/links.json new file mode 100644 index 00000000..fe904e3b --- /dev/null +++ b/concepts/strings/links.json @@ -0,0 +1,14 @@ +[ + { + "url": "https://book.cairo-lang.org/ch02-02-data-types.html#string-types", + "description": "String types in the Cairo book" + }, + { + "url": "https://starknet-by-example.voyager.online/getting-started/basics/bytearrays-strings.html", + "description": "Starknet by Example section on Strings and ByteArrays" + }, + { + "url": "https://docs.starknet.io/architecture-and-concepts/smart-contracts/serialization-of-cairo-types/#serialization_of_byte_arrays", + "description": "Starknet docs explaining how ByteArray is implemented and how it's serialized" + } +] diff --git a/config.json b/config.json index b13e422c..33a2726b 100644 --- a/config.json +++ b/config.json @@ -34,22 +34,72 @@ ] }, "exercises": { - "concept": [], - "practice": [] + "practice": [ + { + "slug": "hello-world", + "name": "Hello World", + "uuid": "1a0e23d9-e8f9-493a-af46-2be040173b64", + "practices": [ + "strings" + ], + "prerequisites": [], + "difficulty": 1, + "topics": [ + "test_driven_development" + ] + } + ] }, - "concepts": [], - "key_features": [], + "concepts": [ + { + "uuid": "4eb800f7-f6c5-4b28-8492-229b6a51829e", + "slug": "strings", + "name": "Strings" + } + ], + "key_features": [ + { + "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.", + "icon": "safe" + }, + { + "title": "Efficient", + "content": "Cairo compiles down to an ad-hoc assembly engineered specifically for efficient proof generation.", + "icon": "fast" + }, + { + "title": "Immutable", + "content": "Cairo uses the immutable memory model, improving data integrity and security.", + "icon": "immutable" + }, + { + "title": "General purpose", + "content": "From onchain gaming to provable ML, Cairo makes building trustless applications possible.", + "icon": "general-purpose" + }, + { + "title": "Innovative", + "content": "Cairo is a fast-growing language that keeps delivering new and exciting features to its developers.", + "icon": "evolving" + } + ], "tags": [ + "execution_mode/compiled", "paradigm/functional", "paradigm/imperative", "paradigm/procedural", - "typing/static", - "typing/strong", - "execution_mode/compiled", - "platform/windows", - "platform/mac", "platform/linux", + "platform/mac", + "platform/windows", "runtime/standalone_executable", + "typing/static", + "typing/strong", "used_for/artificial_intelligence", "used_for/backends", "used_for/financial_systems", diff --git a/exercises/practice/hello-world/.docs/instructions.md b/exercises/practice/hello-world/.docs/instructions.md new file mode 100644 index 00000000..c9570e48 --- /dev/null +++ b/exercises/practice/hello-world/.docs/instructions.md @@ -0,0 +1,16 @@ +# Instructions + +The classical introductory exercise. +Just say "Hello, World!". + +["Hello, World!"][hello-world] is the traditional first program for beginning programming in a new language or environment. + +The objectives are simple: + +- Modify the provided code so that it produces the string "Hello, World!". +- Run the test suite and make sure that it succeeds. +- Submit your solution and check it at the website. + +If everything goes well, you will be ready to fetch your first real exercise. + +[hello-world]: https://en.wikipedia.org/wiki/%22Hello,_world!%22_program diff --git a/exercises/practice/hello-world/.meta/config.json b/exercises/practice/hello-world/.meta/config.json new file mode 100644 index 00000000..c7e88cfb --- /dev/null +++ b/exercises/practice/hello-world/.meta/config.json @@ -0,0 +1,20 @@ +{ + "authors": [ + "misicnenad" + ], + "files": { + "solution": [ + "src/lib.cairo", + "Scarb.toml" + ], + "test": [ + "src/tests.cairo" + ], + "example": [ + ".meta/example.cairo" + ] + }, + "blurb": "Exercism's classic introductory exercise. Just say \"Hello, World!\".", + "source": "This is an exercise to introduce users to using Exercism", + "source_url": "https://en.wikipedia.org/wiki/%22Hello,_world!%22_program" +} diff --git a/exercises/practice/hello-world/.meta/example.cairo b/exercises/practice/hello-world/.meta/example.cairo new file mode 100644 index 00000000..d203326b --- /dev/null +++ b/exercises/practice/hello-world/.meta/example.cairo @@ -0,0 +1,3 @@ +fn hello() -> ByteArray { + "Hello, World!" +} diff --git a/exercises/practice/hello-world/.meta/tests.toml b/exercises/practice/hello-world/.meta/tests.toml new file mode 100644 index 00000000..73466d67 --- /dev/null +++ b/exercises/practice/hello-world/.meta/tests.toml @@ -0,0 +1,13 @@ +# 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. + +[af9ffe10-dc13-42d8-a742-e7bdafac449d] +description = "Say Hi!" diff --git a/exercises/practice/hello-world/Scarb.toml b/exercises/practice/hello-world/Scarb.toml new file mode 100644 index 00000000..c09a6b38 --- /dev/null +++ b/exercises/practice/hello-world/Scarb.toml @@ -0,0 +1,4 @@ +[package] +name = "hello_world" +version = "0.1.0" +edition = "2023_11" diff --git a/exercises/practice/hello-world/src/lib.cairo b/exercises/practice/hello-world/src/lib.cairo new file mode 100644 index 00000000..53b70a0c --- /dev/null +++ b/exercises/practice/hello-world/src/lib.cairo @@ -0,0 +1,7 @@ +// ByteArray is a string that's not limited to 31 characters, you'll learn more about this later +fn hello() -> ByteArray { + "Goodbye, Mars!" +} + +#[cfg(test)] +mod tests; diff --git a/exercises/practice/hello-world/src/tests.cairo b/exercises/practice/hello-world/src/tests.cairo new file mode 100644 index 00000000..b7c248e9 --- /dev/null +++ b/exercises/practice/hello-world/src/tests.cairo @@ -0,0 +1,4 @@ +#[test] +fn test_hello_world() { + assert_eq!(hello_world::hello(), "Hello, World!"); +}