[2016][ruby][19.0]

profile
Alpha Chen 8 years ago
parent f3bd338b7d
commit 592d8b2384

@ -0,0 +1,16 @@
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
Loading…
Cancel
Save