summaryrefslogtreecommitdiff
path: root/exercises
diff options
context:
space:
mode:
authormo8it <mo8it@proton.me>2024-05-21 01:47:57 +0200
committermo8it <mo8it@proton.me>2024-05-21 01:47:57 +0200
commit0f4c42d54ea7322a4ee0ae7036c058c3061e80e9 (patch)
treedd72045b9c25da9da24e28842ef89058d83f8647 /exercises
parentbde2524c3b1043da489541d4885592abe16646fa (diff)
Add solutions to intro and variables
Diffstat (limited to 'exercises')
-rw-r--r--exercises/00_intro/intro2.rs4
-rw-r--r--exercises/01_variables/variables1.rs6
-rw-r--r--exercises/01_variables/variables2.rs2
-rw-r--r--exercises/01_variables/variables3.rs4
-rw-r--r--exercises/01_variables/variables4.rs9
-rw-r--r--exercises/01_variables/variables5.rs10
-rw-r--r--exercises/01_variables/variables6.rs4
7 files changed, 25 insertions, 14 deletions
diff --git a/exercises/00_intro/intro2.rs b/exercises/00_intro/intro2.rs
index c7a3ab2..e443ec8 100644
--- a/exercises/00_intro/intro2.rs
+++ b/exercises/00_intro/intro2.rs
@@ -1,5 +1,5 @@
-// Make the code print a greeting to the world.
+// TODO: Fix the code to print "Hello world!".
fn main() {
- printline!("Hello there!")
+ printline!("Hello world!");
}
diff --git a/exercises/01_variables/variables1.rs b/exercises/01_variables/variables1.rs
index 3035bfa..0a9e554 100644
--- a/exercises/01_variables/variables1.rs
+++ b/exercises/01_variables/variables1.rs
@@ -1,6 +1,6 @@
-// Make me compile!
-
fn main() {
+ // TODO: Add missing keyword.
x = 5;
- println!("x has the value {}", x);
+
+ println!("x has the value {x}");
}
diff --git a/exercises/01_variables/variables2.rs b/exercises/01_variables/variables2.rs
index ce2dd85..e2a3603 100644
--- a/exercises/01_variables/variables2.rs
+++ b/exercises/01_variables/variables2.rs
@@ -1,5 +1,7 @@
fn main() {
+ // TODO: Change the line below to fix the compiler error.
let x;
+
if x == 10 {
println!("x is ten!");
} else {
diff --git a/exercises/01_variables/variables3.rs b/exercises/01_variables/variables3.rs
index 488385b..06f35bb 100644
--- a/exercises/01_variables/variables3.rs
+++ b/exercises/01_variables/variables3.rs
@@ -1,4 +1,6 @@
fn main() {
+ // TODO: Change the line below to fix the compiler error.
let x: i32;
- println!("Number {}", x);
+
+ println!("Number {x}");
}
diff --git a/exercises/01_variables/variables4.rs b/exercises/01_variables/variables4.rs
index 67be127..8634ceb 100644
--- a/exercises/01_variables/variables4.rs
+++ b/exercises/01_variables/variables4.rs
@@ -1,6 +1,9 @@
+// TODO: Fix the compiler error.
+
fn main() {
let x = 3;
- println!("Number {}", x);
- x = 5; // don't change this line
- println!("Number {}", x);
+ println!("Number {x}");
+
+ x = 5; // Don't change this line
+ println!("Number {x}");
}
diff --git a/exercises/01_variables/variables5.rs b/exercises/01_variables/variables5.rs
index 3a74541..73f655e 100644
--- a/exercises/01_variables/variables5.rs
+++ b/exercises/01_variables/variables5.rs
@@ -1,6 +1,8 @@
fn main() {
- let number = "T-H-R-E-E"; // don't change this line
- println!("Spell a Number : {}", number);
- number = 3; // don't rename this variable
- println!("Number plus two is : {}", number + 2);
+ let number = "T-H-R-E-E"; // Don't change this line
+ println!("Spell a number: {}", number);
+
+ // TODO: Fix the compiler error by changing the line below without renaming the the variable.
+ number = 3;
+ println!("Number plus two is: {}", number + 2);
}
diff --git a/exercises/01_variables/variables6.rs b/exercises/01_variables/variables6.rs
index 4746331..4a040fd 100644
--- a/exercises/01_variables/variables6.rs
+++ b/exercises/01_variables/variables6.rs
@@ -1,4 +1,6 @@
+// TODO: Change the line below to fix the compiler error.
const NUMBER = 3;
+
fn main() {
- println!("Number {}", NUMBER);
+ println!("Number: {NUMBER}");
}