[2017][ruby][11.x] speedrun

sorbet
Alpha Chen 7 years ago
parent 8872c7cbc7
commit 6cff27d507

File diff suppressed because one or more lines are too long

@ -0,0 +1,26 @@
dirs = ARGF.read.strip.split(?,)
current = [0, 0, 0]
max = 0
dirs.each do |dir|
delta = case dir
when "nw"
[-1, 1, 0]
when "n"
[0, 1, -1]
when "ne"
[1, 0, -1]
when "sw"
[-1, 0, 1]
when "s"
[0, -1, 1]
when "se"
[1, -1, 0]
else
raise "omg!"
end
current = current.zip(delta).map {|a,b| a + b }
max = [max, current.map(&:abs).sum / 2].max
end
p current
p current.map(&:abs).sum / 2
p max
Loading…
Cancel
Save