rustfmt
This commit is contained in:
@ -3,14 +3,14 @@
|
||||
enum Move {
|
||||
ROCK = 1,
|
||||
PAPER = 2,
|
||||
SCISSORS = 3
|
||||
SCISSORS = 3,
|
||||
}
|
||||
|
||||
#[repr(u8)]
|
||||
enum Outcome {
|
||||
LOSS = 0,
|
||||
DRAW = 3,
|
||||
WIN = 6
|
||||
WIN = 6,
|
||||
}
|
||||
|
||||
impl TryFrom<char> for Move {
|
||||
@ -38,12 +38,9 @@ impl std::fmt::Display for Move {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
fn main() {
|
||||
const INPUT: &str = include_str!("../input.txt");
|
||||
|
||||
|
||||
let mut your_score: u64 = 0;
|
||||
let mut their_score: u64 = 0;
|
||||
|
||||
@ -60,15 +57,24 @@ fn main() {
|
||||
let outcome: Outcome;
|
||||
if their_move == your_move {
|
||||
outcome = Outcome::DRAW
|
||||
}
|
||||
else if their_move == Move::ROCK {
|
||||
outcome = if your_move == Move::PAPER { Outcome::WIN } else { Outcome::LOSS };
|
||||
}
|
||||
else if their_move == Move::PAPER {
|
||||
outcome = if your_move == Move::SCISSORS { Outcome::WIN } else { Outcome::LOSS };
|
||||
}
|
||||
else {
|
||||
outcome = if your_move == Move::ROCK { Outcome::WIN } else { Outcome::LOSS };
|
||||
} else if their_move == Move::ROCK {
|
||||
outcome = if your_move == Move::PAPER {
|
||||
Outcome::WIN
|
||||
} else {
|
||||
Outcome::LOSS
|
||||
};
|
||||
} else if their_move == Move::PAPER {
|
||||
outcome = if your_move == Move::SCISSORS {
|
||||
Outcome::WIN
|
||||
} else {
|
||||
Outcome::LOSS
|
||||
};
|
||||
} else {
|
||||
outcome = if your_move == Move::ROCK {
|
||||
Outcome::WIN
|
||||
} else {
|
||||
Outcome::LOSS
|
||||
};
|
||||
}
|
||||
|
||||
let outcome: u64 = outcome as u64;
|
||||
|
Reference in New Issue
Block a user