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/2016/ruby/day_19.rb

17 lines
258 B

Elf = Struct.new(:id, :presents)
n = 3017957
elves = Array.new(n) {|i| Elf.new(i+1, 1) }
until elves.size == 1
elf = elves.shift
next if elf.presents.zero?
elf.presents += elves.first.presents
elves.first.presents = 0
elves << elf
end
p elves