day 02
This commit is contained in:
parent
a49f204feb
commit
462782ad30
@ -1,5 +1,4 @@
|
|||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
const DRAW_SCORE: i32 = 3;
|
const DRAW_SCORE: i32 = 3;
|
||||||
const WIN_SCORE: i32 = 6;
|
const WIN_SCORE: i32 = 6;
|
||||||
const LOSE_SCORE: i32 = 0;
|
const LOSE_SCORE: i32 = 0;
|
||||||
@ -79,7 +78,7 @@ fn find_needed_shape_for_right(left: &str, win_state: WinState) -> String {
|
|||||||
},
|
},
|
||||||
WinState::Error => todo!(),
|
WinState::Error => todo!(),
|
||||||
};
|
};
|
||||||
return String::from(shape);
|
String::from(shape)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_complicated_result(left: &str, right: &str) -> i32 {
|
fn find_complicated_result(left: &str, right: &str) -> i32 {
|
||||||
@ -104,20 +103,20 @@ fn find_result(left: &str, right: &str) -> i32 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn shape_score(shape: Shape) -> i32 {
|
fn shape_score(shape: Shape) -> i32 {
|
||||||
return match shape {
|
match shape {
|
||||||
Shape::Rock => 1,
|
Shape::Rock => 1,
|
||||||
Shape::Paper => 2,
|
Shape::Paper => 2,
|
||||||
Shape::Scissors => 3,
|
Shape::Scissors => 3,
|
||||||
Shape::Error => 0,
|
Shape::Error => 0,
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
fn string_to_shape(shapestring: &str) -> Shape {
|
fn string_to_shape(shapestring: &str) -> Shape {
|
||||||
return match shapestring {
|
match shapestring {
|
||||||
"A" | "X" => Shape::Rock,
|
"A" | "X" => Shape::Rock,
|
||||||
"B" | "Y" => Shape::Paper,
|
"B" | "Y" => Shape::Paper,
|
||||||
"C" | "Z" => Shape::Scissors,
|
"C" | "Z" => Shape::Scissors,
|
||||||
_ => Shape::Error,
|
_ => Shape::Error,
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
Loading…
Reference in New Issue
Block a user