Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
224 changes: 223 additions & 1 deletion dev-Cargo.toml
Binary file added exercises/00_intro/intro1.exe
Binary file not shown.
Binary file added exercises/00_intro/intro1.pdb
Binary file not shown.
1 change: 1 addition & 0 deletions exercises/00_intro/intro1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ fn main() {
println!("The file of this exercise is `exercises/00_intro/intro1.rs`. Have a look!");
println!("The current exercise path will be always shown under the progress bar.");
println!("You can click on the path to open the exercise file in your editor.");
println!("This is how we start.");
}
Binary file added exercises/00_intro/intro2.exe
Binary file not shown.
Binary file added exercises/00_intro/intro2.pdb
Binary file not shown.
2 changes: 1 addition & 1 deletion exercises/00_intro/intro2.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
fn main() {
// TODO: Fix the code to print "Hello world!".
printline!("Hello world!");
println!("Hello world!");
}
Binary file added exercises/01_variables/variables1.exe
Binary file not shown.
Binary file added exercises/01_variables/variables1.pdb
Binary file not shown.
4 changes: 2 additions & 2 deletions exercises/01_variables/variables1.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
fn main() {
// TODO: Add the missing keyword.
x = 5;
let x = 5;

println!("x has the value {x}");
println!("x has the value {x}");// format {variable}
}
Binary file added exercises/01_variables/variables2.exe
Binary file not shown.
Binary file added exercises/01_variables/variables2.pdb
Binary file not shown.
2 changes: 1 addition & 1 deletion exercises/01_variables/variables2.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
fn main() {
// TODO: Change the line below to fix the compiler error.
let x;
let x = 10;

if x == 10 {
println!("x is ten!");
Expand Down
Binary file added exercises/01_variables/variables3.exe
Binary file not shown.
Binary file added exercises/01_variables/variables3.pdb
Binary file not shown.
2 changes: 1 addition & 1 deletion exercises/01_variables/variables3.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
fn main() {
// TODO: Change the line below to fix the compiler error.
let x: i32;
let x: i32 = 0;

println!("Number {x}");
}
Binary file added exercises/01_variables/variables4.exe
Binary file not shown.
Binary file added exercises/01_variables/variables4.pdb
Binary file not shown.
2 changes: 1 addition & 1 deletion exercises/01_variables/variables4.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// TODO: Fix the compiler error.
fn main() {
let x = 3;
let mut x = 3;
println!("Number {x}");

x = 5; // Don't change this line
Expand Down
Binary file added exercises/01_variables/variables5.exe
Binary file not shown.
Binary file added exercises/01_variables/variables5.pdb
Binary file not shown.
2 changes: 1 addition & 1 deletion exercises/01_variables/variables5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ fn main() {
println!("Spell a number: {number}");

// TODO: Fix the compiler error by changing the line below without renaming the variable.
number = 3;
let number = 3;
println!("Number plus two is: {}", number + 2);
}
Binary file added exercises/01_variables/variables6.exe
Binary file not shown.
Binary file added exercises/01_variables/variables6.pdb
Binary file not shown.
2 changes: 1 addition & 1 deletion exercises/01_variables/variables6.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// TODO: Change the line below to fix the compiler error.
const NUMBER = 3;
const NUMBER: i32 = 3;

fn main() {
println!("Number: {NUMBER}");
Expand Down
Binary file added exercises/02_functions/functions1.exe
Binary file not shown.
Binary file added exercises/02_functions/functions1.pdb
Binary file not shown.
3 changes: 3 additions & 0 deletions exercises/02_functions/functions1.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// TODO: Add some function with the name `call_me` without arguments or a return value.
fn call_me() {
println!("Called!");
}

fn main() {
call_me(); // Don't change this line
Expand Down
Binary file added exercises/02_functions/functions2.exe
Binary file not shown.
Binary file added exercises/02_functions/functions2.pdb
Binary file not shown.
2 changes: 1 addition & 1 deletion exercises/02_functions/functions2.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// TODO: Add the missing type of the argument `num` after the colon `:`.
fn call_me(num:) {
fn call_me(num: i32) {
for i in 0..num {
println!("Ring! Call number {}", i + 1);
}
Expand Down
Binary file added exercises/02_functions/functions3.exe
Binary file not shown.
Binary file added exercises/02_functions/functions3.pdb
Binary file not shown.
2 changes: 1 addition & 1 deletion exercises/02_functions/functions3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ fn call_me(num: u8) {

fn main() {
// TODO: Fix the function call.
call_me();
call_me(3);
}
Binary file added exercises/02_functions/functions4.exe
Binary file not shown.
Binary file added exercises/02_functions/functions4.pdb
Binary file not shown.
2 changes: 1 addition & 1 deletion exercises/02_functions/functions4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fn is_even(num: i64) -> bool {
}

// TODO: Fix the function signature.
fn sale_price(price: i64) -> {
fn sale_price(price: i64) -> i64{
if is_even(price) {
price - 10
} else {
Expand Down
Binary file added exercises/02_functions/functions5.exe
Binary file not shown.
Binary file added exercises/02_functions/functions5.pdb
Binary file not shown.
2 changes: 1 addition & 1 deletion exercises/02_functions/functions5.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// TODO: Fix the function body without changing the signature.
fn square(num: i32) -> i32 {
num * num;
num * num
}

fn main() {
Expand Down
Binary file added exercises/03_if/if1.exe
Binary file not shown.
Binary file added exercises/03_if/if1.pdb
Binary file not shown.
7 changes: 6 additions & 1 deletion exercises/03_if/if1.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
fn bigger(a: i32, b: i32) -> i32 {
if a > b {
a
} else {
b
}
// TODO: Complete this function to return the bigger number!
// If both numbers are equal, any of them can be returned.
// Do not use:
Expand All @@ -7,7 +12,7 @@ fn bigger(a: i32, b: i32) -> i32 {
}

fn main() {
// You can optionally experiment here.
println!("The bigger number is {}", bigger(89,30));// You can optionally experiment here.
}

// Don't mind this for now :)
Expand Down
Binary file added exercises/03_if/if2.exe
Binary file not shown.
Binary file added exercises/03_if/if2.pdb
Binary file not shown.
6 changes: 4 additions & 2 deletions exercises/03_if/if2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
fn picky_eater(food: &str) -> &str {
if food == "strawberry" {
"Yummy!"
} else if food == "potato" {
"I guess I can eat that."
} else {
1
"No thanks!"
}
}

fn main() {
// You can optionally experiment here.
println!("The food is {}", picky_eater("strawberry"));
}

// TODO: Read the tests to understand the desired behavior.
Expand Down
Binary file added exercises/03_if/if3.exe
Binary file not shown.
Binary file added exercises/03_if/if3.pdb
Binary file not shown.
8 changes: 5 additions & 3 deletions exercises/03_if/if3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ fn animal_habitat(animal: &str) -> &str {
let identifier = if animal == "crab" {
1
} else if animal == "gopher" {
2.0
2
} else if animal == "snake" {
3
} else {
"Unknown"
4
};

// Don't change the expression below!
Expand All @@ -23,7 +23,9 @@ fn animal_habitat(animal: &str) -> &str {
}

fn main() {
// You can optionally experiment here.
let animal: &str = "gopher";
println!("The habitat of a {animal} is {}", animal_habitat(animal));
// You can optionally experiment here.
}

// Don't change the tests!
Expand Down
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions exercises/04_primitive_types/primitive_types1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ fn main() {
// TODO: Define a boolean variable with the name `is_evening` before the `if` statement below.
// The value of the variable should be the negation (opposite) of `is_morning`.
// let …
let is_evening = !is_morning;
if is_evening {
println!("Good evening!");
}
Expand Down
Binary file not shown.
Binary file added exercises/04_primitive_types/primitive_types2.pdb
Binary file not shown.
Loading
Loading