lib/aoc2021/puzzles/amphipod.rb
# Returns a list of pieces that can make at least one valid move.
Returns a list of pieces that can make at least one valid move.
Returns a list of pieces that can make at least one valid move .
def ready_to_move
        @board.each_with_index.map { |thing_at_pos, x|
          case thing_at_pos
            in AMPHIPODS
              can_move_to_room?(x) ? x : nil
            in Array => room
              y = room.each_index.find { room[_1] } 
              y && (can_move_from_room_spot?(x, y) ? [x, y] : nil)
            else
              nil
          end
        }.compact
      end
def ready_to_move @board . each_with_index . map { | thing_at_pos , x | case thing_at_pos in AMPHIPODS can_move_to_room? ( x ) ? x : nil in Array => room y = room . each_index . find { room [ _1 ] } y && ( can_move_from_room_spot? ( x , y ) ? [ x , y ] : nil ) else nil end } . compact end
Returns a list of pieces that can make at least one valid move.
Returns a list of pieces that can make at least one valid move .
# != nil