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.
|
stones = DATA.read.scan(/\d+/).map(&:to_i)
|
|
|
|
25.times {
|
|
stones = stones.flat_map {|n|
|
|
if n.zero?
|
|
[1]
|
|
elsif (s = n.to_s.size) && s.even?
|
|
[n.to_s[0...s/2], n.to_s[s/2..]].map(&:to_i)
|
|
else
|
|
[n * 2024]
|
|
end
|
|
}
|
|
}
|
|
|
|
pp stones.length
|
|
|
|
__END__
|
|
1750884 193 866395 7 1158 31 35216 0
|