mirror of
https://github.com/rust-lang/rustlings.git
synced 2025-12-30 15:39:17 +00:00
First commit during exercises
This commit is contained in:
parent
8d0aa11a35
commit
ba0854d324
@ -13,8 +13,6 @@
|
|||||||
// Execute `rustlings hint intro1` or use the `hint` watch subcommand for a
|
// Execute `rustlings hint intro1` or use the `hint` watch subcommand for a
|
||||||
// hint.
|
// hint.
|
||||||
|
|
||||||
// I AM NOT DONE
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("Hello and");
|
println!("Hello and");
|
||||||
println!(r#" welcome to... "#);
|
println!(r#" welcome to... "#);
|
||||||
|
|||||||
@ -5,8 +5,6 @@
|
|||||||
// Execute `rustlings hint intro2` or use the `hint` watch subcommand for a
|
// Execute `rustlings hint intro2` or use the `hint` watch subcommand for a
|
||||||
// hint.
|
// hint.
|
||||||
|
|
||||||
// I AM NOT DONE
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
printline!("Hello there!")
|
println!("Hello there!")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,9 +5,7 @@
|
|||||||
// Execute `rustlings hint variables1` or use the `hint` watch subcommand for a
|
// Execute `rustlings hint variables1` or use the `hint` watch subcommand for a
|
||||||
// hint.
|
// hint.
|
||||||
|
|
||||||
// I AM NOT DONE
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
x = 5;
|
let x = 5;
|
||||||
println!("x has the value {}", x);
|
println!("x has the value {}", x);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,10 +3,9 @@
|
|||||||
// Execute `rustlings hint variables2` or use the `hint` watch subcommand for a
|
// Execute `rustlings hint variables2` or use the `hint` watch subcommand for a
|
||||||
// hint.
|
// hint.
|
||||||
|
|
||||||
// I AM NOT DONE
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let x;
|
let x: i32 = 10;
|
||||||
if x == 10 {
|
if x == 10 {
|
||||||
println!("x is ten!");
|
println!("x is ten!");
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -3,9 +3,7 @@
|
|||||||
// Execute `rustlings hint variables3` or use the `hint` watch subcommand for a
|
// Execute `rustlings hint variables3` or use the `hint` watch subcommand for a
|
||||||
// hint.
|
// hint.
|
||||||
|
|
||||||
// I AM NOT DONE
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let x: i32;
|
let x: i32 = 56;
|
||||||
println!("Number {}", x);
|
println!("Number {}", x);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,10 +3,9 @@
|
|||||||
// Execute `rustlings hint variables4` or use the `hint` watch subcommand for a
|
// Execute `rustlings hint variables4` or use the `hint` watch subcommand for a
|
||||||
// hint.
|
// hint.
|
||||||
|
|
||||||
// I AM NOT DONE
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let x = 3;
|
let mut x: i32 = 3;
|
||||||
println!("Number {}", x);
|
println!("Number {}", x);
|
||||||
x = 5; // don't change this line
|
x = 5; // don't change this line
|
||||||
println!("Number {}", x);
|
println!("Number {}", x);
|
||||||
|
|||||||
@ -3,11 +3,10 @@
|
|||||||
// Execute `rustlings hint variables5` or use the `hint` watch subcommand for a
|
// Execute `rustlings hint variables5` or use the `hint` watch subcommand for a
|
||||||
// hint.
|
// hint.
|
||||||
|
|
||||||
// I AM NOT DONE
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let number = "T-H-R-E-E"; // don't change this line
|
let number = "T-H-R-E-E"; // don't change this line
|
||||||
println!("Spell a Number : {}", number);
|
println!("Spell a Number : {}", number);
|
||||||
number = 3; // don't rename this variable
|
let number: i32 = 3; // don't rename this variable
|
||||||
println!("Number plus two is : {}", number + 2);
|
println!("Number plus two is : {}", number + 2);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,9 +3,9 @@
|
|||||||
// Execute `rustlings hint variables6` or use the `hint` watch subcommand for a
|
// Execute `rustlings hint variables6` or use the `hint` watch subcommand for a
|
||||||
// hint.
|
// hint.
|
||||||
|
|
||||||
// I AM NOT DONE
|
|
||||||
|
|
||||||
const NUMBER = 3;
|
|
||||||
|
const NUMBER: i8 = 3;
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("Number {}", NUMBER);
|
println!("Number {}", NUMBER);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,8 +3,12 @@
|
|||||||
// Execute `rustlings hint functions1` or use the `hint` watch subcommand for a
|
// Execute `rustlings hint functions1` or use the `hint` watch subcommand for a
|
||||||
// hint.
|
// hint.
|
||||||
|
|
||||||
// I AM NOT DONE
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
call_me();
|
call_me();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn call_me() {
|
||||||
|
println!("Hello");
|
||||||
|
}
|
||||||
|
|||||||
@ -3,14 +3,14 @@
|
|||||||
// Execute `rustlings hint functions2` or use the `hint` watch subcommand for a
|
// Execute `rustlings hint functions2` or use the `hint` watch subcommand for a
|
||||||
// hint.
|
// hint.
|
||||||
|
|
||||||
// I AM NOT DONE
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
call_me(3);
|
call_me(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn call_me(num:) {
|
fn call_me(num:i32) {
|
||||||
for i in 0..num {
|
for i in 0..num {
|
||||||
println!("Ring! Call number {}", i + 1);
|
println!("Ring! Call number {}", i+1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,10 +3,9 @@
|
|||||||
// Execute `rustlings hint functions3` or use the `hint` watch subcommand for a
|
// Execute `rustlings hint functions3` or use the `hint` watch subcommand for a
|
||||||
// hint.
|
// hint.
|
||||||
|
|
||||||
// I AM NOT DONE
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
call_me();
|
call_me(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn call_me(num: u32) {
|
fn call_me(num: u32) {
|
||||||
|
|||||||
@ -8,14 +8,13 @@
|
|||||||
// Execute `rustlings hint functions4` or use the `hint` watch subcommand for a
|
// Execute `rustlings hint functions4` or use the `hint` watch subcommand for a
|
||||||
// hint.
|
// hint.
|
||||||
|
|
||||||
// I AM NOT DONE
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let original_price = 51;
|
let original_price = 51;
|
||||||
println!("Your sale price is {}", sale_price(original_price));
|
println!("Your sale price is {}", sale_price(original_price));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sale_price(price: i32) -> {
|
fn sale_price(price: i32) -> i32{
|
||||||
if is_even(price) {
|
if is_even(price) {
|
||||||
price - 10
|
price - 10
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
// Execute `rustlings hint functions5` or use the `hint` watch subcommand for a
|
// Execute `rustlings hint functions5` or use the `hint` watch subcommand for a
|
||||||
// hint.
|
// hint.
|
||||||
|
|
||||||
// I AM NOT DONE
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let answer = square(3);
|
let answer = square(3);
|
||||||
@ -11,5 +11,5 @@ fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn square(num: i32) -> i32 {
|
fn square(num: i32) -> i32 {
|
||||||
num * num;
|
num * num
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,13 +2,17 @@
|
|||||||
//
|
//
|
||||||
// Execute `rustlings hint if1` or use the `hint` watch subcommand for a hint.
|
// Execute `rustlings hint if1` or use the `hint` watch subcommand for a hint.
|
||||||
|
|
||||||
// I AM NOT DONE
|
|
||||||
|
|
||||||
pub fn bigger(a: i32, b: i32) -> i32 {
|
pub fn bigger(a: i32, b: i32) -> i32 {
|
||||||
// Complete this function to return the bigger number!
|
// Complete this function to return the bigger number!
|
||||||
// Do not use:
|
// Do not use:
|
||||||
// - another function call
|
// - another function call
|
||||||
// - additional variables
|
// - additional variables
|
||||||
|
if a > b {
|
||||||
|
a
|
||||||
|
} else {
|
||||||
|
b
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't mind this for now :)
|
// Don't mind this for now :)
|
||||||
|
|||||||
@ -5,13 +5,14 @@
|
|||||||
//
|
//
|
||||||
// Execute `rustlings hint if2` or use the `hint` watch subcommand for a hint.
|
// Execute `rustlings hint if2` or use the `hint` watch subcommand for a hint.
|
||||||
|
|
||||||
// I AM NOT DONE
|
|
||||||
|
|
||||||
pub fn foo_if_fizz(fizzish: &str) -> &str {
|
pub fn foo_if_fizz(fizzish: &str) -> &str {
|
||||||
if fizzish == "fizz" {
|
if fizzish == "fizz" {
|
||||||
"foo"
|
"foo"
|
||||||
|
} else if fizzish == "fuzz" {
|
||||||
|
"bar"
|
||||||
} else {
|
} else {
|
||||||
1
|
"baz"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
0
rmeta0ryf3V/lib.rmeta
Normal file
0
rmeta0ryf3V/lib.rmeta
Normal file
0
rmeta2aSc3x/lib.rmeta
Normal file
0
rmeta2aSc3x/lib.rmeta
Normal file
0
rmeta33i6If/lib.rmeta
Normal file
0
rmeta33i6If/lib.rmeta
Normal file
0
rmeta5Wxz3U/lib.rmeta
Normal file
0
rmeta5Wxz3U/lib.rmeta
Normal file
0
rmeta6SLzTY/lib.rmeta
Normal file
0
rmeta6SLzTY/lib.rmeta
Normal file
0
rmeta6d4cEP/lib.rmeta
Normal file
0
rmeta6d4cEP/lib.rmeta
Normal file
0
rmeta6ydyc4/lib.rmeta
Normal file
0
rmeta6ydyc4/lib.rmeta
Normal file
0
rmeta7BJqFE/lib.rmeta
Normal file
0
rmeta7BJqFE/lib.rmeta
Normal file
0
rmetaADFDqC/lib.rmeta
Normal file
0
rmetaADFDqC/lib.rmeta
Normal file
0
rmetaC5KoMd/lib.rmeta
Normal file
0
rmetaC5KoMd/lib.rmeta
Normal file
0
rmetaCZBhUm/lib.rmeta
Normal file
0
rmetaCZBhUm/lib.rmeta
Normal file
0
rmetaG8ggMd/lib.rmeta
Normal file
0
rmetaG8ggMd/lib.rmeta
Normal file
0
rmetaI9CfM1/lib.rmeta
Normal file
0
rmetaI9CfM1/lib.rmeta
Normal file
0
rmetaJdmzg3/lib.rmeta
Normal file
0
rmetaJdmzg3/lib.rmeta
Normal file
0
rmetaL1loEt/lib.rmeta
Normal file
0
rmetaL1loEt/lib.rmeta
Normal file
0
rmetaLqB2Pt/lib.rmeta
Normal file
0
rmetaLqB2Pt/lib.rmeta
Normal file
0
rmetaMILKnS/lib.rmeta
Normal file
0
rmetaMILKnS/lib.rmeta
Normal file
0
rmetaOLfFya/lib.rmeta
Normal file
0
rmetaOLfFya/lib.rmeta
Normal file
0
rmetaOUjPNE/lib.rmeta
Normal file
0
rmetaOUjPNE/lib.rmeta
Normal file
0
rmetaSWrvVl/lib.rmeta
Normal file
0
rmetaSWrvVl/lib.rmeta
Normal file
0
rmetaUuliaM/lib.rmeta
Normal file
0
rmetaUuliaM/lib.rmeta
Normal file
0
rmetaVBOY8B/lib.rmeta
Normal file
0
rmetaVBOY8B/lib.rmeta
Normal file
0
rmetaVYqrhZ/lib.rmeta
Normal file
0
rmetaVYqrhZ/lib.rmeta
Normal file
0
rmetaVYslhO/lib.rmeta
Normal file
0
rmetaVYslhO/lib.rmeta
Normal file
0
rmetaWPqumJ/lib.rmeta
Normal file
0
rmetaWPqumJ/lib.rmeta
Normal file
0
rmetaXAwDJn/lib.rmeta
Normal file
0
rmetaXAwDJn/lib.rmeta
Normal file
0
rmetaaRaIoY/lib.rmeta
Normal file
0
rmetaaRaIoY/lib.rmeta
Normal file
0
rmetaasPVKX/lib.rmeta
Normal file
0
rmetaasPVKX/lib.rmeta
Normal file
0
rmetabDKu8I/lib.rmeta
Normal file
0
rmetabDKu8I/lib.rmeta
Normal file
0
rmetacxdTWN/lib.rmeta
Normal file
0
rmetacxdTWN/lib.rmeta
Normal file
0
rmetaetiEOc/lib.rmeta
Normal file
0
rmetaetiEOc/lib.rmeta
Normal file
0
rmetafBXx3N/lib.rmeta
Normal file
0
rmetafBXx3N/lib.rmeta
Normal file
0
rmetahurnUg/lib.rmeta
Normal file
0
rmetahurnUg/lib.rmeta
Normal file
0
rmetamn1kMA/lib.rmeta
Normal file
0
rmetamn1kMA/lib.rmeta
Normal file
0
rmetan35lXf/lib.rmeta
Normal file
0
rmetan35lXf/lib.rmeta
Normal file
0
rmetancNxZE/lib.rmeta
Normal file
0
rmetancNxZE/lib.rmeta
Normal file
0
rmetanuq7Cb/lib.rmeta
Normal file
0
rmetanuq7Cb/lib.rmeta
Normal file
0
rmetanwtydK/lib.rmeta
Normal file
0
rmetanwtydK/lib.rmeta
Normal file
0
rmetaqrY8vE/lib.rmeta
Normal file
0
rmetaqrY8vE/lib.rmeta
Normal file
0
rmetas4kYOR/lib.rmeta
Normal file
0
rmetas4kYOR/lib.rmeta
Normal file
0
rmetayvCQVv/lib.rmeta
Normal file
0
rmetayvCQVv/lib.rmeta
Normal file
0
rmetazA76Xs/lib.rmeta
Normal file
0
rmetazA76Xs/lib.rmeta
Normal file
0
rmetazTHYWp/lib.rmeta
Normal file
0
rmetazTHYWp/lib.rmeta
Normal file
0
rmetazkI4QF/lib.rmeta
Normal file
0
rmetazkI4QF/lib.rmeta
Normal file
Loading…
x
Reference in New Issue
Block a user