lib/aoc2021/puzzles/amphipod.rb
# Focused on detecting a clear path between rooms 2, 4, 6, and 8
# Always pass in the left room number as start_pos, and the number
# of steps to check (2, 4, or 6) as dist.
Focused on detecting a clear path between rooms 2, 4, 6, and 8
Always pass in the left room number as start_pos, and the number
of steps to check (2, 4, or 6) as dist.
Focused on detecting a clear path between rooms 2 4 6 and 8 Always pass in the left room number as start_pos and the number of steps to check ( 2 4 or 6 ) as dist .
def path?(start_pos, dist)
        return true if dist.zero?
        board[(start_pos + 1...start_pos + dist).step(2)].compact.empty?
      end
def path? ( start_pos , dist ) return true if dist . zero? board [ ( start_pos + 1 ... start_pos + dist ) . step ( 2 ) ] . compact . empty? end
Focused on detecting a clear path between rooms 2, 4, 6, and 8
Always pass in the left room number as start_pos, and the number
of steps to check (2, 4, or 6) as dist.
Focused on detecting a clear path between rooms 2 4 6 and 8 Always pass in the left room number as start_pos and the number of steps to check ( 2 4 or 6 ) as dist .
# let mask = ((2 << (dist - 1)) - 1) << (5 - dist - start); # self.hallway.flatten() & mask == 0
start_pos
<not_specific>
dist
<not_specific>