Exemple #1
0
from aoc import aoc

with open("test/11_input.txt") as f:
    seats_raw = f.read().splitlines()
    seats = []
    for row in seats_raw:
        row = list(row)
        seats.append(row)

    waiting_area = aoc.WaitingArea(seats)
    steps = waiting_area.run()

    print("11-1: %s" % waiting_area.count_occupied())

    waiting_area = aoc.WaitingArea(seats, max_depth=None, neighbor_threshold=5)
    steps = waiting_area.run()

    print("11-2: %s" % waiting_area.count_occupied())
Exemple #2
0
 def test_count_occupied_neighbors_visible_sightline(self):
     waiting_area = aoc.WaitingArea(
         [["#", ".", "#"], ["#", "#", "#"], ["#", ".", "#"]],
         max_depth=None)
     self.assertEqual(3, waiting_area.count_occupied_neighbors(0, 0))
Exemple #3
0
 def test_count_occupied_neighbors_empty_seat_in_sightline(self):
     waiting_area = aoc.WaitingArea([[".", "L", ".", "L", "#"]],
                                    max_depth=None)
     self.assertEqual(0, waiting_area.count_occupied_neighbors(0, 0))
Exemple #4
0
 def test_waiting_area_step(self):
     waiting_area = aoc.WaitingArea([["#", "#", "#"], ["#", "#", "#"],
                                     ["#", ".", "#"]])
     self.assertEqual("#", waiting_area.get_seat((1, 0)))
     waiting_area.step()
     self.assertEqual("L", waiting_area.get_seat((1, 0)))
Exemple #5
0
 def test_count_occupied_neighbors_medium(self):
     waiting_area = aoc.WaitingArea([["#", ".", "#"], ["#", "#", "#"],
                                     ["#", ".", "#"]])
     self.assertEqual(3, waiting_area.count_occupied_neighbors(0, 1))
     self.assertEqual(6, waiting_area.count_occupied_neighbors(1, 1))
Exemple #6
0
 def test_count_occupied_neighbors_square(self):
     waiting_area = aoc.WaitingArea([["L", "#"], ["#", "#"]])
     self.assertEqual(3, waiting_area.count_occupied_neighbors(0, 0))
     self.assertEqual(2, waiting_area.count_occupied_neighbors(0, 1))
Exemple #7
0
 def test_count_occupied_neighbors(self):
     waiting_area = aoc.WaitingArea([["L", "#"]])
     self.assertEqual(1, waiting_area.count_occupied_neighbors(0, 0))
     self.assertEqual(0, waiting_area.count_occupied_neighbors(1, 0))
Exemple #8
0
 def test_get_seat(self):
     waiting_area = aoc.WaitingArea([["L", "#"]])
     self.assertEqual("L", waiting_area.get_seat((0, 0)))
     self.assertEqual("#", waiting_area.get_seat((1, 0)))