|
|
@ -10,6 +10,10 @@ class State
|
|
|
|
Floor.new(items.reject {|item| item == ?. })
|
|
|
|
Floor.new(items.reject {|item| item == ?. })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def ==(state)
|
|
|
|
|
|
|
|
elevator == state.elevator && floors.zip(state.floors).all? {|a,b| a == b }
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
class Floor < SimpleDelegator
|
|
|
|
class Floor < SimpleDelegator
|
|
|
@ -51,4 +55,9 @@ F1 E . HM . LM
|
|
|
|
assert_equal %w[ H L ], floor.microchips
|
|
|
|
assert_equal %w[ H L ], floor.microchips
|
|
|
|
assert_empty floor.generators
|
|
|
|
assert_empty floor.generators
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_equality
|
|
|
|
|
|
|
|
state = State.new(INPUT)
|
|
|
|
|
|
|
|
assert_equal @state, state
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|