blob: 871a3321f8f15614a5f9e0e83c92908fa9cc819f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
def whatplay(them, outcome)
case them
when 1
case outcome
when 0; 3
when 3; 1
when 6; 2
end
when 2
case outcome
when 0; 1
when 3; 2
when 6; 3
end
when 3
case outcome
when 0; 2
when 3; 3
when 6; 1
end
end
end
rounds = $stdin.readlines.map(&:strip).map(&:split)
score = 0
rounds.each do |them, outcome|
ti = {?A => 1, ?B => 2, ?C => 3}[them]
oi = {?X => 0, ?Y => 3, ?Z => 6}[outcome]
score += whatplay(ti, oi)
score += oi
end
puts score
|