Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
micknudsen committed Dec 1, 2023
2 parents 5bd590b + 2b57c15 commit 59b79c7
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
40 changes: 40 additions & 0 deletions 2015/10/code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import unittest

from itertools import groupby


def say(number: str) -> str:
return "".join(f"{len(list(group))}{digit}" for digit, group in groupby(number))


class TestCode(unittest.TestCase):
def test_say(self) -> None:
self.assertEqual(say(number="1"), "11")
self.assertEqual(say(number="11"), "21")
self.assertEqual(say(number="21"), "1211")
self.assertEqual(say(number="1211"), "111221")
self.assertEqual(say(number="111221"), "312211")


class TestPuzzles(unittest.TestCase):
def setUp(self) -> None:
with open("input.txt") as f:
self.number = f.read().splitlines()[0]

def test_part_one(self) -> None:
solution = self.number
for _ in range(40):
solution = say(solution)
self.assertEqual(
len(solution),
492982,
)

def test_part_two(self) -> None:
solution = self.number
for _ in range(50):
solution = say(solution)
self.assertEqual(
len(solution),
6989950,
)
1 change: 1 addition & 0 deletions 2015/10/input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1321131112

0 comments on commit 59b79c7

Please sign in to comment.