Skip to content

Commit

Permalink
Fix bug in win scoring, refs #3
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Dec 3, 2022
1 parent c1f2e5f commit 15fc966
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion 02/rock-paper-scissors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@ fn main() -> io::Result<()> {
let opponent = parts.next().unwrap();
let me = parts.next().unwrap();

/*
A/X = rock
B/Y = paper
C/Z = scissors
*/

// Who won? Opponent A beats me Z, B beats me X, C beats me Y
let win_score = match (opponent, me) {
("A", "Z") | ("B", "X") | ("C", "Y") => 0,
("A", "X") | ("B", "Y") | ("C", "Z") => 6,
("A", "Y") | ("B", "Z") | ("C", "X") => 6,
_ => 3,
};
score += win_score;
Expand Down

0 comments on commit 15fc966

Please sign in to comment.