[2021][ruby][13.x] refactor

pull/2/head
Alpha Chen 3 years ago
parent 963a61b14e
commit 4d7ad2055f

@ -4,17 +4,13 @@ dots = dots.scan(/(\d+),(\d+)/).map { _1.map(&:to_i) }
folds = folds.scan(/(x|y)=(\d+)/).map { [_1, _2.to_i] }
folds.each do |dir, axis|
case dir
when ?x
dots.select {|x,y| x > axis }.each do |dot|
dot[0] = axis - (dot[0] - axis)
index = case dir
when ?x then 0
when ?y then 1
else fail
end
when ?y
dots.select {|x,y| y > axis }.each do |dot|
dot[1] = axis - (dot[1] - axis)
end
else
fail
dots.select { _1[index] > axis }.each do |dot|
dot[index] = axis - (dot[index] - axis)
end
dots.uniq!
# p dots.size or exit

Loading…
Cancel
Save