rustfmt
This commit is contained in:
+11
-5
@@ -15,7 +15,7 @@ impl RPS {
|
||||
'A' | 'X' => Rock,
|
||||
'B' | 'Y' => Paper,
|
||||
'C' | 'Z' => Scissor,
|
||||
_ => panic!()
|
||||
_ => panic!(),
|
||||
}
|
||||
}
|
||||
pub fn score(self) -> u32 {
|
||||
@@ -48,7 +48,7 @@ impl Outcome {
|
||||
'X' => Loss,
|
||||
'Y' => Draw,
|
||||
'Z' => Win,
|
||||
_ => panic!()
|
||||
_ => panic!(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ impl Outcome {
|
||||
match self {
|
||||
Win => 6,
|
||||
Draw => 3,
|
||||
Loss => 0
|
||||
Loss => 0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,9 +73,15 @@ fn main() -> Result<(), Error> {
|
||||
let mut total_score_p1 = 0;
|
||||
let mut total_score_p2 = 0;
|
||||
for line in read_to_string("input.txt")?.split("\n") {
|
||||
if line.is_empty() { continue }
|
||||
if line.is_empty() {
|
||||
continue;
|
||||
}
|
||||
let (opponent, you) = (line.chars().nth(0).unwrap(), line.chars().nth(2).unwrap());
|
||||
let (opponent, your_move, outcome) = (RPS::from_char(opponent), RPS::from_char(you), Outcome::from_char(you));
|
||||
let (opponent, your_move, outcome) = (
|
||||
RPS::from_char(opponent),
|
||||
RPS::from_char(you),
|
||||
Outcome::from_char(you),
|
||||
);
|
||||
let score_p1 = your_move.score() + RPS::outcome(opponent, your_move).score();
|
||||
total_score_p1 += score_p1;
|
||||
let score_p2 = outcome.score() + outcome.for_opponent(opponent).score();
|
||||
|
||||
Reference in New Issue
Block a user