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.
23 lines
477 B
23 lines
477 B
stones = DATA.read.scan(/\d+/).map(&:to_i)
|
|
|
|
blink = Hash.new {|h, k|
|
|
n, times = k
|
|
h[k] = if times.zero?
|
|
1
|
|
elsif n.zero?
|
|
h[[1, times-1]]
|
|
elsif n.digits.length.even?
|
|
a, b = n.divmod(10**(d.length/2))
|
|
h[[a, times-1]] + h[[b, times-1]]
|
|
else
|
|
h[[n*2024, times-1]]
|
|
end
|
|
}
|
|
|
|
pp stones.sum { blink[[_1, 6]] }
|
|
pp stones.sum { blink[[_1, 25]] }
|
|
pp stones.sum { blink[[_1, 75]] }
|
|
|
|
__END__
|
|
125 17
|