, +Destruct>(self: Option, predicate: P) -> Option`\n* `fn append_span, +Drop>(ref self: Array, span: Span)`",
+ "expected": "fn main() {\n call_me(3);\n}\n\nfn call_me(num: u32) {\n println!(\"num is {}\", num);\n}"
+ },
+ {
+ "query": "Complete the following Cairo code:\n\n```cairo\n// I AM NOT DONE\n\nfn main() {\n let number = 1_u8; // don't change this line\n println!(\"number is {}\", number);\n number = 3; // don't rename this variable\n println!(\"number is {}\", number);\n}\n```\n\nHint: In variables4 we already learned how to make an immutable variable mutable\nusing a special keyword. Unfortunately this doesn't help us much in this exercise\nbecause we want to assign a different typed value to an existing variable. Sometimes\nyou may also like to reuse existing variable names because you are just converting\nvalues to different types like in this exercise.\nFortunately Cairo has a powerful solution to this problem: 'Shadowing'!\nYou can see an example of variables and 'shadowing' here: https://book.cairo-lang.org/ch02-01-variables-and-mutability.html?highlight=shadow#shadowing\nYou can read about the different integer types here: https://book.cairo-lang.org/ch02-02-data-types.html#integer-types\nTry to solve this exercise afterwards using this technique.",
+ "chat_history": "",
+ "context": "In Cairo, variables are immutable by default. Once a value is bound to a name, you cannot change that value. To make a variable mutable, you use the `mut` keyword. However, `mut` only allows changing the *value* of a variable, not its *type*.\n\n**Shadowing**\nCairo provides a feature called \"shadowing,\" which allows you to declare a *new* variable with the same name as a previous variable. This new variable \"shadows\" the old one, meaning the new variable is what the compiler will see when you use that name. This is particularly useful when you want to transform a value from one type to another but keep the same variable name.\n\n**Syntax for Shadowing:**\nYou use the `let` keyword again to declare the new variable, even if it has the same name.\n\n**Example of Shadowing:**\n```cairo\nfn main() {\n let x = 5; // x is an integer\n let x = x + 1; // x is shadowed, new x is 6\n let x = \"hello\"; // x is shadowed again, new x is a string (different type)\n}\n```\n\n**Integer Types in Cairo:**\nCairo supports various integer types, which are specified using suffixes for literals:\n* `u8`: 8-bit unsigned integer (e.g., `1_u8`)\n* `u16`: 16-bit unsigned integer\n* `u32`: 32-bit unsigned integer\n* `u64`: 64-bit unsigned integer\n* `u128`: 128-bit unsigned integer\n* `u256`: 256-bit unsigned integer\n* `felt252`: A field element, which is the native integer type in Cairo, representing values in the range `[0, P - 1]` where `P` is a large prime number. Literals without a suffix often default to `felt252` or infer based on context.\n\nWhen performing operations or assignments, ensure the types are compatible or explicitly cast/shadow to the desired type. Shadowing allows you to re-declare a variable with a different integer type, for example, changing from `u8` to `u32` or `felt252`.",
+ "expected": "fn main() {\n let mut number = 1_u8;\n println!(\"number is {}\", number);\n number = 3; // don't rename this variable\n println!(\"number is {}\", number);\n}"
+ },
+ {
+ "query": "Complete the following Cairo code:\n\n```cairo\n// I AM NOT DONE\n\nfn main() {\n let x = 3;\n println!(\"x is {}\", x);\n x = 5; // don't change this line\n println!(\"x is now {}\", x);\n}\n```\n\nHint: In Cairo, variable bindings are immutable by default. But here we're trying\nto reassign a different value to x! There's a keyword we can use to make\na variable binding mutable instead.",
+ "chat_history": "",
+ "context": "In Cairo, variable bindings are immutable by default. To allow a variable to be reassigned or modified after its initial declaration, the `mut` keyword must be used.\n\nFor example, when declaring an array, `mut` is used to make it mutable:\n```cairo,editable\nfn main() {\n // Initialize an empty mutable array\n let mut arr = array![];\n\n // Elements can be appended to a mutable array\n arr.append(1);\n arr.append(2);\n arr.append(3);\n\n println!(\"Array: {:?}\", arr);\n}\n```\n\nMutability of data can also be changed when ownership is transferred, such as when passing a variable to a function that expects a mutable parameter:\n```cairo,editable\nfn modify_array_mut(mut mutable_array: Array) {\n mutable_array.append(4);\n println!(\"mutable_array now contains {:?}\", mutable_array);\n}\n\nfn main() {\n let immutable_array = array![1, 2, 3];\n\n println!(\"immutable_array contains {:?}\", immutable_array);\n\n // Attempting to modify an immutable variable directly would result in a mutability error:\n // immutable_array.append(4); // This line would cause a compilation error\n\n // *Move* the array, changing the ownership (and mutability)\n modify_array_mut(immutable_array);\n}\n```\nWithout the `mut` keyword, attempting to reassign a value to a variable will result in a compilation error, as variables are immutable by default.",
+ "expected": "fn main() {\n let mut x = 3;\n println!(\"x is {}\", x);\n x = 5; // don't change this line\n println!(\"x is now {}\", x);\n}"
+ },
+ {
+ "query": "Complete the following Cairo code:\n\n```cairo\n// I AM NOT DONE\n\nfn main() {\n let x: felt252;\n println!(\"x is {}\", x);\n}\n```\n\nHint: Oops! In this exercise, we have a variable binding that we've created on\nline 7, and we're trying to use it on line 8, but we haven't given it a\nvalue. We can't print out something that isn't there; try giving x a value!\nThis is an error that can cause bugs that's very easy to make in any\nprogramming language -- thankfully the Cairo compiler has caught this for us!",
+ "chat_history": "",
+ "context": "The provided context details various Cairo core library functionalities, including:\n* **`SpanTrait`**: Provides methods for `Span` such as `pop_front`, `pop_back`, `multi_pop_front`, `multi_pop_back`, `slice`, `len`, `get`, and `at`.\n * `fn pop_front(ref self: Span) -> Option<@T>`\n * `fn pop_back(ref self: Span) -> Option<@T>`\n * `fn multi_pop_front(ref self: Span) -> Option>`\n * `fn multi_pop_back(ref self: Span) -> Option>`\n * `fn slice(self: Span, start: u32, length: u32) -> Span`\n * `fn get(self: Span, index: u32) -> Option>`\n* **`ToSpanTrait`**: Converts a data structure into a span.\n * `fn span(self: @C) -> Span`\n* **`ArrayTrait`**: Provides methods for `Array`.\n * `fn append_span, +Drop>(ref self: Array, span: Span)`\n * `fn pop_front