def test_Day10_Example(self): data = [ 'value 5 goes to bot 2', 'bot 2 gives low to bot 1 and high to bot 0', 'value 3 goes to bot 1', 'bot 1 gives low to output 1 and high to bot 0', 'bot 0 gives low to output 2 and high to output 0', 'value 2 goes to bot 2' ] self.assertEqual(day10.solve(data, ['2', '5']), '2')
def test_solve_1_other(self): data = puzzle.parse('''#.#...#.#. .###....#. .#....#... ##.#.#.#.# ....#.#.#. .##..###.# ..#...##.. ..##....## ......#... .####.###.'''.split("\n")) location, numberOfAsteroidSeen = puzzle.solve(data) self.assertEqual(location, (1, 2)) self.assertEqual(numberOfAsteroidSeen, 35)
def test_pass(self): data = puzzle.parse(read_file("10", "1")) location, numberOfAsteroidSeen = puzzle.solve(data) print(f"Solution: {location}, {numberOfAsteroidSeen}") self.assertEqual(location, (29, 28)) self.assertEqual(numberOfAsteroidSeen, 256)
def test_solve_1(self): data = puzzle.parse(["......#.#.", "#..#.#....", "..#######.", ".#.#.###..", ".#..#.....", "..#....#.#", "#..#....#.", ".##.#..###", "##...#..#.", ".#....####"]) location, numberOfAsteroidSeen = puzzle.solve(data) self.assertEqual(location, (5, 8)) self.assertEqual(numberOfAsteroidSeen, 33)
from day10 import solve, dense_hash INPUT = "hxtvlmkl" ones = set() for row_no in range(128): inp = [ord(c) for c in "{}-{}".format(INPUT, row_no)] inp.extend([17, 31, 73, 47, 23]) reverse = solve(64, inp) dense_hash(0, 15, reverse) bin_row = [ b for x in reverse for y in hex(x)[2:].zfill(2) for z in y for b in bin(int(z, 16))[2:].zfill(4) ] for k, v in enumerate(bin_row): if v == '1': ones.add((row_no, k)) def part_1(): return len(ones) directions = ((1, 0), (0, -1), (-1, 0), (0, 1)) def find_regions(one): stack = [one] while stack: (x, y) = stack.pop() for dx, dy in directions:
def test_Day10_2_Data(self): with open('input.txt') as f: data = f.read().splitlines() self.assertEqual(day10.solve(data, part2=True), 1085)
def test_Day10_Data(self): with open('input.txt') as f: data = f.read().splitlines() self.assertEqual(day10.solve(data, ['17', '61']), '157')
def test_pass(self): data = puzzle.parse(read_file("02", "1")) result = puzzle.solve(data) print(f"Solution: {result}") self.assertEqual(True, True)
def testAdd(self): data = [1, 0, 0, 0, 99] answer = puzzle.solve(data) self.assertEqual(True, True)