[2022][ruby][20.x]

pull/1/head
Alpha Chen 2 years ago
parent ce623e16d1
commit 7ced4db4a4
Signed by: alpha
SSH Key Fingerprint: SHA256:3fOT8fiYQG/aK9ntivV3Bqtg8AYQ7q4nV6ZgihOA20g

@ -0,0 +1,19 @@
list = ARGF.read.lines(chomp: true).map(&:to_i)
list = list.map { _1 * 811589153 }
list = list.map.with_index { [_2, _1] }
10.times do
(0...list.size).each do |i|
j = list.index {|ii,_| ii == i }
_, n = list.delete_at(j)
j += n
j %= list.size
list.insert(j, [i, n])
end
end
list = list.map(&:last)
i = list.index(0)
p [1000, 2000, 3000].sum { list.fetch((i + _1) % list.size) }
Loading…
Cancel
Save