diff options
author | Nat Lasseter <user@4574.co.uk> | 2022-12-15 14:51:23 +0000 |
---|---|---|
committer | Nat Lasseter <user@4574.co.uk> | 2022-12-15 14:51:23 +0000 |
commit | 03ed9fc34c2d6738dcca9fe4bb5c4ccffd587ae1 (patch) | |
tree | 30ecc26a2425f49ea29e9bc8fd5c2be85bcdbad6 /day15/part2.rb | |
parent | 9f1b752bbd96c53f974e0cca4af6c1412102e62d (diff) |
o i dum
Diffstat (limited to 'day15/part2.rb')
-rw-r--r-- | day15/part2.rb | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/day15/part2.rb b/day15/part2.rb index cb3219d..e7ba5d3 100644 --- a/day15/part2.rb +++ b/day15/part2.rb @@ -17,26 +17,27 @@ class Sensor def edge edges = [] - at = [@x, @y - (@range + 1)] - until at[1] == @y - edges << at - at[0] += 1 - at[1] += 1 + atx = @x + aty = @y - (@range + 1) + until aty == @y + edges << [atx, aty] + atx += 1 + aty += 1 end - until at[0] == @x - edges << at - at[0] -= 1 - at[1] += 1 + until atx == @x + edges << [atx, aty] + atx -= 1 + aty += 1 end - until at[1] == @y - edges << at - at[0] -= 1 - at[1] -= 1 + until aty == @y + edges << [atx, aty] + atx -= 1 + aty -= 1 end - until at[0] == @x - edges << at - at[0] += 1 - at[1] -= 1 + until atx == @x + edges << [atx, aty] + atx += 1 + aty -= 1 end edges end |