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.
17 lines
258 B
17 lines
258 B
8 years ago
|
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
|