Skip to content

Commit 15fc966

Browse files
committed
Fix bug in win scoring, refs #3
1 parent c1f2e5f commit 15fc966

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

02/rock-paper-scissors.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,16 @@ fn main() -> io::Result<()> {
1515
let opponent = parts.next().unwrap();
1616
let me = parts.next().unwrap();
1717

18+
/*
19+
A/X = rock
20+
B/Y = paper
21+
C/Z = scissors
22+
*/
23+
1824
// Who won? Opponent A beats me Z, B beats me X, C beats me Y
1925
let win_score = match (opponent, me) {
2026
("A", "Z") | ("B", "X") | ("C", "Y") => 0,
21-
("A", "X") | ("B", "Y") | ("C", "Z") => 6,
27+
("A", "Y") | ("B", "Z") | ("C", "X") => 6,
2228
_ => 3,
2329
};
2430
score += win_score;

0 commit comments

Comments
 (0)