Skip to content

Commit

Permalink
Less extreme code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
micknudsen committed Dec 1, 2023
1 parent 24fbc78 commit 486df80
Showing 1 changed file with 15 additions and 84 deletions.
99 changes: 15 additions & 84 deletions 2015/01/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,89 +62,27 @@ def deliver_presents(

class TestCode(unittest.TestCase):
def test_deliver_presents(self) -> None:
self.assertEqual(
deliver_presents(
instructions="(())",
),
0,
)
self.assertEqual(
deliver_presents(
instructions="()()",
),
0,
)
self.assertEqual(
deliver_presents(
instructions="(((",
),
3,
)
self.assertEqual(
deliver_presents(
instructions="(()(()(",
),
3,
)
self.assertEqual(
deliver_presents(
instructions="))(((((",
),
3,
)
self.assertEqual(
deliver_presents(
instructions="())",
),
-1,
)
self.assertEqual(
deliver_presents(
instructions="))(",
),
-1,
)
self.assertEqual(
deliver_presents(
instructions=")))",
),
-3,
)
self.assertEqual(
deliver_presents(
instructions=")())())",
),
-3,
)
self.assertEqual(deliver_presents(instructions="(())"), 0)
self.assertEqual(deliver_presents(instructions="()()"), 0)
self.assertEqual(deliver_presents(instructions="((("), 3)
self.assertEqual(deliver_presents(instructions="(()(()("), 3)
self.assertEqual(deliver_presents(instructions="))((((("), 3)
self.assertEqual(deliver_presents(instructions="())"), -1)
self.assertEqual(deliver_presents(instructions="))("), -1)
self.assertEqual(deliver_presents(instructions=")))"), -3)
self.assertEqual(deliver_presents(instructions=")())())"), -3)

def test_deliver_presents_with_stop(self) -> None:
self.assertEqual(
deliver_presents(
instructions=")",
stop=-1,
),
1,
)
self.assertEqual(
deliver_presents(
instructions="()())",
stop=-1,
),
5,
)
self.assertEqual(deliver_presents(instructions=")", stop=-1), 1)
self.assertEqual(deliver_presents(instructions="()())", stop=-1), 5)

def test_deliver_presents_invalid_instruction(self) -> None:
with self.assertRaises(InvalidInstructionError):
deliver_presents(
instructions=")[(",
)
deliver_presents(instructions=")[(")

def test_deliver_presents_with_stop_floor_never_reached(self) -> None:
with self.assertRaises(FloorNeverReachedError):
deliver_presents(
instructions="(",
stop=-1,
)
deliver_presents(instructions="(", stop=-1)


class TestPuzzle(unittest.TestCase):
Expand All @@ -153,16 +91,9 @@ def setUp(self) -> None:
self.instructions = f.read()

def test_part_one(self) -> None:
self.assertEqual(
deliver_presents(instructions=self.instructions),
232,
)
self.assertEqual(deliver_presents(instructions=self.instructions), 232)

def test_part_two(self) -> None:
self.assertEqual(
deliver_presents(
instructions=self.instructions,
stop=-1,
),
1783,
deliver_presents(instructions=self.instructions, stop=-1), 1783
)

0 comments on commit 486df80

Please sign in to comment.