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/2017/ruby/day_01.rb

6 lines
204 B

# p ARGF.read.strip.chars.map(&:to_i).each_cons(2).select {|a,b| a == b }.map(&:first).sum
a = ARGF.read.strip.chars.map(&:to_i)
b = a.rotate(a.size/2)
p a.zip(b).select {|a,b| a == b }.map(&:first).sum