You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
advent-of-code/2022/ruby/day_02.rb

15 lines
318 B

p ARGF.read.strip.lines(chomp: true).map(&:split).map {|a,b|
a = a.ord - ?A.ord
b = b.ord - ?X.ord
# part 2
b = (a + b - 1) % 3
outcome = case
when (a + 1) % 3 == b then 6
when a == b then 3
else 0
end
outcome + b + 1
}.sum