2022-12-04 10:12:00 +00:00
|
|
|
lines = ARGF.read.split("\n")
|
|
|
|
part1 = part2 = 0
|
2022-12-02 06:22:17 +00:00
|
|
|
|
2022-12-04 10:12:00 +00:00
|
|
|
lines.each do |line|
|
2022-12-02 06:22:17 +00:00
|
|
|
theirs = line[0].ord - 'A'.ord
|
|
|
|
ours = line[2].ord - 'X'.ord
|
|
|
|
|
2022-12-04 10:12:00 +00:00
|
|
|
part1 += ours + [4, 7, 1][(ours - theirs) % 3]
|
|
|
|
part2 += [1, 4, 7][ours] + (theirs + ours - 1) % 3
|
2022-12-02 06:22:17 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
puts part1, part2
|