finished day 3
This commit is contained in:
		
							parent
							
								
									9c95528e76
								
							
						
					
					
						commit
						64e7a253f2
					
				
					 6 changed files with 418 additions and 9 deletions
				
			
		
							
								
								
									
										9
									
								
								Pipfile.lock
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										9
									
								
								Pipfile.lock
									
										
									
										generated
									
									
									
								
							| 
						 | 
					@ -1,7 +1,7 @@
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    "_meta": {
 | 
					    "_meta": {
 | 
				
			||||||
        "hash": {
 | 
					        "hash": {
 | 
				
			||||||
            "sha256": "bf24791e041f80c18b2c667226aa3b47e25ebb5779ca595d076d8cf87f785918"
 | 
					            "sha256": "1a3671b568f0cf9b012b6e7415c1952a33c8121d6876697499fff3dbdb69783f"
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        "pipfile-spec": 6,
 | 
					        "pipfile-spec": 6,
 | 
				
			||||||
        "requires": {
 | 
					        "requires": {
 | 
				
			||||||
| 
						 | 
					@ -39,13 +39,6 @@
 | 
				
			||||||
            "markers": "python_version >= '3.6'",
 | 
					            "markers": "python_version >= '3.6'",
 | 
				
			||||||
            "version": "==21.3"
 | 
					            "version": "==21.3"
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        "parse": {
 | 
					 | 
				
			||||||
            "hashes": [
 | 
					 | 
				
			||||||
                "sha256:9ff82852bcb65d139813e2a5197627a94966245c897796760a3a2a8eb66f020b"
 | 
					 | 
				
			||||||
            ],
 | 
					 | 
				
			||||||
            "index": "pypi",
 | 
					 | 
				
			||||||
            "version": "==1.19.0"
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        "pluggy": {
 | 
					        "pluggy": {
 | 
				
			||||||
            "hashes": [
 | 
					            "hashes": [
 | 
				
			||||||
                "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159",
 | 
					                "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										38
									
								
								day3/day3.py
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										38
									
								
								day3/day3.py
									
										
									
									
									
										Executable file
									
								
							| 
						 | 
					@ -0,0 +1,38 @@
 | 
				
			||||||
 | 
					#! /usr/bin/env python3
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import pathlib
 | 
				
			||||||
 | 
					import sys
 | 
				
			||||||
 | 
					import re
 | 
				
			||||||
 | 
					from dataclasses import dataclass
 | 
				
			||||||
 | 
					from pprint import pprint
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def parse(puzzle_input: str):
 | 
				
			||||||
 | 
					    """Parse input"""
 | 
				
			||||||
 | 
					    # returns a 2 dimentional array where true means there is a tree there.
 | 
				
			||||||
 | 
					    return [[i=='#' for i in j] for j in puzzle_input.splitlines()]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def part1(data):
 | 
				
			||||||
 | 
					    """Solve part 1"""
 | 
				
			||||||
 | 
					    return solveForSlope(data, 3, 1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def solveForSlope(data, right: int, down: int):
 | 
				
			||||||
 | 
					    return sum(1 for index, row in enumerate(data[::down]) if row[(right*index)%len(row)])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def part2(data):
 | 
				
			||||||
 | 
					    """Solve part 2"""
 | 
				
			||||||
 | 
					    return solveForSlope(data,1,1)*solveForSlope(data,3,1)*solveForSlope(data,5,1)*solveForSlope(data,7,1)*solveForSlope(data,1,2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def solve(puzzle_input):
 | 
				
			||||||
 | 
					    """Solve the puzzle for the given input"""
 | 
				
			||||||
 | 
					    data = parse(puzzle_input)
 | 
				
			||||||
 | 
					    solution1 = part1(data)
 | 
				
			||||||
 | 
					    solution2 = part2(data)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return solution1, solution2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == "__main__":
 | 
				
			||||||
 | 
					    for path in sys.argv[1:]:
 | 
				
			||||||
 | 
					        print(f"{path}:")
 | 
				
			||||||
 | 
					        puzzle_input = pathlib.Path(path).read_text().strip()
 | 
				
			||||||
 | 
					        solutions = solve(puzzle_input)
 | 
				
			||||||
 | 
					        print("\n".join(str(solution) for solution in solutions))
 | 
				
			||||||
							
								
								
									
										11
									
								
								day3/example1
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								day3/example1
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,11 @@
 | 
				
			||||||
 | 
					..##.......
 | 
				
			||||||
 | 
					#...#...#..
 | 
				
			||||||
 | 
					.#....#..#.
 | 
				
			||||||
 | 
					..#.#...#.#
 | 
				
			||||||
 | 
					.#...##..#.
 | 
				
			||||||
 | 
					..#.##.....
 | 
				
			||||||
 | 
					.#.#.#....#
 | 
				
			||||||
 | 
					.#........#
 | 
				
			||||||
 | 
					#.##...#...
 | 
				
			||||||
 | 
					#...##....#
 | 
				
			||||||
 | 
					.#..#...#.#
 | 
				
			||||||
							
								
								
									
										323
									
								
								day3/input
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										323
									
								
								day3/input
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,323 @@
 | 
				
			||||||
 | 
					........#.............#........
 | 
				
			||||||
 | 
					...#....#...#....#.............
 | 
				
			||||||
 | 
					.#..#...#............#.....#..#
 | 
				
			||||||
 | 
					..#......#..##............###..
 | 
				
			||||||
 | 
					..........#......#..#..#.......
 | 
				
			||||||
 | 
					.#..#.......#.........#.#......
 | 
				
			||||||
 | 
					.........#..#....##..#.##....#.
 | 
				
			||||||
 | 
					..#....##...#..................
 | 
				
			||||||
 | 
					##..........#.##...#....##..#..
 | 
				
			||||||
 | 
					...#....#...#..............#...
 | 
				
			||||||
 | 
					...........................#..#
 | 
				
			||||||
 | 
					..##.##.#..................#...
 | 
				
			||||||
 | 
					...#.##..#............#........
 | 
				
			||||||
 | 
					........#.......#...#.....##.#.
 | 
				
			||||||
 | 
					.##..........#......#.......#..
 | 
				
			||||||
 | 
					...#..........#...#..#.......#.
 | 
				
			||||||
 | 
					......#...#...#.##.......#.#...
 | 
				
			||||||
 | 
					........#...#...#...##.........
 | 
				
			||||||
 | 
					#..............#.#....#.......#
 | 
				
			||||||
 | 
					..#..#..#.#....#...............
 | 
				
			||||||
 | 
					.....#........#...#..........#.
 | 
				
			||||||
 | 
					##......#...#..#.##.......#....
 | 
				
			||||||
 | 
					..#.#.....#.#.............#.#.#
 | 
				
			||||||
 | 
					#..#..##......##...#...........
 | 
				
			||||||
 | 
					..#......#........#.....#......
 | 
				
			||||||
 | 
					.....#.......#....#.#...#......
 | 
				
			||||||
 | 
					...#........#...........#...#..
 | 
				
			||||||
 | 
					.......#.#...........###....#..
 | 
				
			||||||
 | 
					...#...........##....##........
 | 
				
			||||||
 | 
					#....#..####....#.....#..#....#
 | 
				
			||||||
 | 
					..........#...........#........
 | 
				
			||||||
 | 
					...#.......#....#.#.........#..
 | 
				
			||||||
 | 
					....#...#.......#..###.........
 | 
				
			||||||
 | 
					......#......#..#......#..#....
 | 
				
			||||||
 | 
					...#.....#............#..#.....
 | 
				
			||||||
 | 
					...#.#.#.#..#.......#.....#....
 | 
				
			||||||
 | 
					#....##...#.........#...##.....
 | 
				
			||||||
 | 
					#..#.......#..#..#..#...##.....
 | 
				
			||||||
 | 
					#.......#............#.....#...
 | 
				
			||||||
 | 
					.#........##....##...#........#
 | 
				
			||||||
 | 
					.....#...#.....................
 | 
				
			||||||
 | 
					.......#........#..............
 | 
				
			||||||
 | 
					.....#............#.#.#...#.#..
 | 
				
			||||||
 | 
					.....##..#.............#.......
 | 
				
			||||||
 | 
					..#.##..#........#..#...#......
 | 
				
			||||||
 | 
					.........#.#....#...........#..
 | 
				
			||||||
 | 
					.#.....#..#....#.....#...#.....
 | 
				
			||||||
 | 
					....#.#................#.......
 | 
				
			||||||
 | 
					...............##......#...#...
 | 
				
			||||||
 | 
					.##...#...#.......##.#....#....
 | 
				
			||||||
 | 
					............#........#.......#.
 | 
				
			||||||
 | 
					......##.#.#...................
 | 
				
			||||||
 | 
					.#.#..............#.......#....
 | 
				
			||||||
 | 
					#.....#...#.......#..#...#.....
 | 
				
			||||||
 | 
					.............#....#..#......#..
 | 
				
			||||||
 | 
					........#...##................#
 | 
				
			||||||
 | 
					.......#...#..#..##............
 | 
				
			||||||
 | 
					..#..#...##...#..#.#.....#...#.
 | 
				
			||||||
 | 
					.#.#...#.........#.#...........
 | 
				
			||||||
 | 
					...###....#.......#...#........
 | 
				
			||||||
 | 
					........#......##.#...#..##..#.
 | 
				
			||||||
 | 
					.....................#.#.......
 | 
				
			||||||
 | 
					.............#...........#...#.
 | 
				
			||||||
 | 
					#..#..#.....#.#...#............
 | 
				
			||||||
 | 
					...#....#.....#...........#....
 | 
				
			||||||
 | 
					..##.....##...#......#..##.....
 | 
				
			||||||
 | 
					#.....#.....###.#.....#....##..
 | 
				
			||||||
 | 
					.#...........###...............
 | 
				
			||||||
 | 
					..................#..##.#...#..
 | 
				
			||||||
 | 
					................#....##.#......
 | 
				
			||||||
 | 
					.#.#.#...#....#.........#..#.#.
 | 
				
			||||||
 | 
					#.......#........##............
 | 
				
			||||||
 | 
					.......##.#....#.#............#
 | 
				
			||||||
 | 
					..........#..##.#....#.........
 | 
				
			||||||
 | 
					........##..#....#.............
 | 
				
			||||||
 | 
					.........#....#...........##...
 | 
				
			||||||
 | 
					#.........#.#..#..#..........#.
 | 
				
			||||||
 | 
					.....#........#......#.........
 | 
				
			||||||
 | 
					....#.#.#...............#......
 | 
				
			||||||
 | 
					.#..#..##...#.##..........#....
 | 
				
			||||||
 | 
					..#....................#.#.....
 | 
				
			||||||
 | 
					.........#....#...........#.#.#
 | 
				
			||||||
 | 
					........#....##.##.............
 | 
				
			||||||
 | 
					..#.....#.......#..#......#....
 | 
				
			||||||
 | 
					#..........#.#.....#.#....#....
 | 
				
			||||||
 | 
					........##.#.....#..#.....#.#..
 | 
				
			||||||
 | 
					...................#...#....#.#
 | 
				
			||||||
 | 
					............#..#....#...#...#..
 | 
				
			||||||
 | 
					..............#.#.........#....
 | 
				
			||||||
 | 
					...#..#..#.#..##..##...........
 | 
				
			||||||
 | 
					.#...........................#.
 | 
				
			||||||
 | 
					.#.......#...........#....#.#.#
 | 
				
			||||||
 | 
					......#..#...#........#...##...
 | 
				
			||||||
 | 
					.........#......#.#.......#...#
 | 
				
			||||||
 | 
					...#..##................#......
 | 
				
			||||||
 | 
					.............#.#..##....#.#....
 | 
				
			||||||
 | 
					...............#..#......#.....
 | 
				
			||||||
 | 
					.#......#.#.#....#........#....
 | 
				
			||||||
 | 
					........#..#.##..#..#.........#
 | 
				
			||||||
 | 
					...#....#.#...#..#.......#..#..
 | 
				
			||||||
 | 
					..#...##.........#..#...#......
 | 
				
			||||||
 | 
					...#...........#.............#.
 | 
				
			||||||
 | 
					....#.....................#....
 | 
				
			||||||
 | 
					.....#..#...............#.#...#
 | 
				
			||||||
 | 
					....#..........#........#......
 | 
				
			||||||
 | 
					..#....#........##..##.........
 | 
				
			||||||
 | 
					...#....#..#.#.......#...#.....
 | 
				
			||||||
 | 
					..#........#....#...##....#.#..
 | 
				
			||||||
 | 
					.#...#........##.....#....###..
 | 
				
			||||||
 | 
					#....#....##......#........#...
 | 
				
			||||||
 | 
					.........#..#.#..........#....#
 | 
				
			||||||
 | 
					....#...#.....#.......##.......
 | 
				
			||||||
 | 
					..............#..........#.##..
 | 
				
			||||||
 | 
					#...#..#..............#......#.
 | 
				
			||||||
 | 
					.................#......##....#
 | 
				
			||||||
 | 
					..#..##..#.......#..#.#......#.
 | 
				
			||||||
 | 
					.............#........#.....#.#
 | 
				
			||||||
 | 
					.#.##............#..#..........
 | 
				
			||||||
 | 
					..#...#...........#..##........
 | 
				
			||||||
 | 
					.#....#...#....#.......#.......
 | 
				
			||||||
 | 
					...#.#..#..#..#....#.....#..#..
 | 
				
			||||||
 | 
					....#..##..............#...#...
 | 
				
			||||||
 | 
					#..........###......###........
 | 
				
			||||||
 | 
					.##.##......#..#............#..
 | 
				
			||||||
 | 
					.#...........#.#.....#...#.....
 | 
				
			||||||
 | 
					#.#..#...#............#........
 | 
				
			||||||
 | 
					.........#...#...#..........##.
 | 
				
			||||||
 | 
					.......###..#..........#.......
 | 
				
			||||||
 | 
					...........###.....#........#..
 | 
				
			||||||
 | 
					.#.............#.....#......#..
 | 
				
			||||||
 | 
					...#.....#....#.#.........##...
 | 
				
			||||||
 | 
					....##..##...#.......##........
 | 
				
			||||||
 | 
					......#....##.........#......#.
 | 
				
			||||||
 | 
					..........#.....##..#.....#..#.
 | 
				
			||||||
 | 
					..........####...#..#.........#
 | 
				
			||||||
 | 
					.##....#..#.#...#.......#......
 | 
				
			||||||
 | 
					...#.#.##.#.#...#....#.#.#.....
 | 
				
			||||||
 | 
					.........#...##........##.....#
 | 
				
			||||||
 | 
					..#........#..........##...##.#
 | 
				
			||||||
 | 
					##...##..........#.#...........
 | 
				
			||||||
 | 
					..............#......#.........
 | 
				
			||||||
 | 
					........#.....#.#.......#......
 | 
				
			||||||
 | 
					.#...#.....#....#.#..#.........
 | 
				
			||||||
 | 
					.....#....................##...
 | 
				
			||||||
 | 
					....#..................#.#...##
 | 
				
			||||||
 | 
					.....#............#..##........
 | 
				
			||||||
 | 
					#..........#....#.#.......##.#.
 | 
				
			||||||
 | 
					....#..#.....................#.
 | 
				
			||||||
 | 
					#..#....##.....#...............
 | 
				
			||||||
 | 
					..#...#..#..##....#.#..........
 | 
				
			||||||
 | 
					.......#......#.#.......#.....#
 | 
				
			||||||
 | 
					...#.#.......#...#.##..........
 | 
				
			||||||
 | 
					....#..........#....#.#.#......
 | 
				
			||||||
 | 
					.......#..#..........#..##.....
 | 
				
			||||||
 | 
					#......#......#...#......#...#.
 | 
				
			||||||
 | 
					###..#....##......##........#..
 | 
				
			||||||
 | 
					.#..........#.....#.......#.#..
 | 
				
			||||||
 | 
					.......#.....#.....#.#.........
 | 
				
			||||||
 | 
					..#...#....#...................
 | 
				
			||||||
 | 
					..............#.##.............
 | 
				
			||||||
 | 
					.#...#.......#.##...#.#.......#
 | 
				
			||||||
 | 
					.......#......................#
 | 
				
			||||||
 | 
					....#.#...#.#........#.........
 | 
				
			||||||
 | 
					.#......#....#...#.............
 | 
				
			||||||
 | 
					#.......#...###.....#.#.#..#...
 | 
				
			||||||
 | 
					#....##.#...............##.....
 | 
				
			||||||
 | 
					..#.......#..................#.
 | 
				
			||||||
 | 
					.....####...............#......
 | 
				
			||||||
 | 
					.##......#......#.#.......##.#.
 | 
				
			||||||
 | 
					#......##..###....#....#......#
 | 
				
			||||||
 | 
					.##.......##.##...#.##.........
 | 
				
			||||||
 | 
					......##............#.......#..
 | 
				
			||||||
 | 
					......#..#.....##.#............
 | 
				
			||||||
 | 
					.#..........#.....##...........
 | 
				
			||||||
 | 
					#.........#......#......##.#...
 | 
				
			||||||
 | 
					.........#.......#..#......#.#.
 | 
				
			||||||
 | 
					.........#.......#...........#.
 | 
				
			||||||
 | 
					.#..##.#..................##...
 | 
				
			||||||
 | 
					.............#.............#...
 | 
				
			||||||
 | 
					.....##........#......##...##..
 | 
				
			||||||
 | 
					..#..#.#.....#..#....#.........
 | 
				
			||||||
 | 
					.....#....#.....#.....#........
 | 
				
			||||||
 | 
					#......##.....#....#....#......
 | 
				
			||||||
 | 
					#.................#..#.#......#
 | 
				
			||||||
 | 
					.......#..#......#....#.#...#.#
 | 
				
			||||||
 | 
					....#.........#..#..........#.#
 | 
				
			||||||
 | 
					##......#............#...#...#.
 | 
				
			||||||
 | 
					....##......#...#.....#....##..
 | 
				
			||||||
 | 
					.#...##.........#..............
 | 
				
			||||||
 | 
					......#.....................#..
 | 
				
			||||||
 | 
					..#..........###....#..........
 | 
				
			||||||
 | 
					#....#...#..#.............#....
 | 
				
			||||||
 | 
					#........#.#......#....#.......
 | 
				
			||||||
 | 
					.#...#.......#..#...#.#...#..#.
 | 
				
			||||||
 | 
					................##.#.....#.....
 | 
				
			||||||
 | 
					###.......#...#................
 | 
				
			||||||
 | 
					...#.......#...#.#.....#.......
 | 
				
			||||||
 | 
					..#.........#.....#.#.......#..
 | 
				
			||||||
 | 
					......#.......................#
 | 
				
			||||||
 | 
					#.....#.#..#....#.......#......
 | 
				
			||||||
 | 
					...#....#..#....####...........
 | 
				
			||||||
 | 
					.............#.....#...##......
 | 
				
			||||||
 | 
					.......#.........#...#..#......
 | 
				
			||||||
 | 
					.##..#.........#....#.#........
 | 
				
			||||||
 | 
					....##...#.#...........#....#..
 | 
				
			||||||
 | 
					.........................##....
 | 
				
			||||||
 | 
					..###.......##....#.#.........#
 | 
				
			||||||
 | 
					.#....#.#.#...........##....#..
 | 
				
			||||||
 | 
					......#...#..#..#..#..#.......#
 | 
				
			||||||
 | 
					..#....#.#.......#..#..#..#...#
 | 
				
			||||||
 | 
					.....##...#.##....#.#...#......
 | 
				
			||||||
 | 
					.........#..#....#..#..........
 | 
				
			||||||
 | 
					.##..##.........#.#.....#......
 | 
				
			||||||
 | 
					..........#...##...#.#...#.....
 | 
				
			||||||
 | 
					#.##..#..#.............#.......
 | 
				
			||||||
 | 
					...#...........#.......#......#
 | 
				
			||||||
 | 
					.......#....#....#...##.......#
 | 
				
			||||||
 | 
					..#.##........###..#......#....
 | 
				
			||||||
 | 
					...#...........###......#..#..#
 | 
				
			||||||
 | 
					.#.........#.#.........#.#.....
 | 
				
			||||||
 | 
					##.......##.##.##......##......
 | 
				
			||||||
 | 
					............#...#..........#...
 | 
				
			||||||
 | 
					....................#..........
 | 
				
			||||||
 | 
					...#..#...........#...#...#....
 | 
				
			||||||
 | 
					.................#...#......###
 | 
				
			||||||
 | 
					...#................#.#.##.....
 | 
				
			||||||
 | 
					...............#........#......
 | 
				
			||||||
 | 
					#.............##......#.#..#...
 | 
				
			||||||
 | 
					..#.#.....#..#.##.....##...#...
 | 
				
			||||||
 | 
					......#.........#......#.......
 | 
				
			||||||
 | 
					#.......#......#....#........#.
 | 
				
			||||||
 | 
					.#..##.....#.........#.........
 | 
				
			||||||
 | 
					....##.##.#...#.........##.#...
 | 
				
			||||||
 | 
					...............#..#..#..##.....
 | 
				
			||||||
 | 
					.#..#...............###........
 | 
				
			||||||
 | 
					.##............##..............
 | 
				
			||||||
 | 
					...............#...##...#...#.#
 | 
				
			||||||
 | 
					..#.#......#.#..#.............#
 | 
				
			||||||
 | 
					#.#..#..##.........#.#.#...#...
 | 
				
			||||||
 | 
					....##.#....................##.
 | 
				
			||||||
 | 
					.........#..#.....#.....#..#..#
 | 
				
			||||||
 | 
					....#......#......#.##....#....
 | 
				
			||||||
 | 
					........###..#.............#..#
 | 
				
			||||||
 | 
					##................#.........#..
 | 
				
			||||||
 | 
					#.....#.......#....#...........
 | 
				
			||||||
 | 
					..#.......#..#........#....#...
 | 
				
			||||||
 | 
					..#.#.##..#.#...##........#.##.
 | 
				
			||||||
 | 
					..#..........#............#....
 | 
				
			||||||
 | 
					..........#...............##...
 | 
				
			||||||
 | 
					..........###........#.#.......
 | 
				
			||||||
 | 
					.....###..#.............#......
 | 
				
			||||||
 | 
					##.............#...#.....#.....
 | 
				
			||||||
 | 
					.....#......#....#........#.#..
 | 
				
			||||||
 | 
					............#..#..............#
 | 
				
			||||||
 | 
					.................#...........##
 | 
				
			||||||
 | 
					#........#.........###.....#...
 | 
				
			||||||
 | 
					..#.#..............##......#.#.
 | 
				
			||||||
 | 
					.#...........#.........#..##..#
 | 
				
			||||||
 | 
					...............................
 | 
				
			||||||
 | 
					.#.....#..#....#....#......#...
 | 
				
			||||||
 | 
					.#...#......#.#..#....#.......#
 | 
				
			||||||
 | 
					......#.##.......#......#......
 | 
				
			||||||
 | 
					......#..###..#................
 | 
				
			||||||
 | 
					#..#.....#........##...#.......
 | 
				
			||||||
 | 
					......##.........##....#...##..
 | 
				
			||||||
 | 
					.#..........#.................#
 | 
				
			||||||
 | 
					#..#.......#...............#...
 | 
				
			||||||
 | 
					.........#..###....#.#.##.#....
 | 
				
			||||||
 | 
					..#...#.##..##...............##
 | 
				
			||||||
 | 
					.........#.....................
 | 
				
			||||||
 | 
					.#....##...#......#....#.......
 | 
				
			||||||
 | 
					............#..........#..#....
 | 
				
			||||||
 | 
					...#......##....#....#........#
 | 
				
			||||||
 | 
					.#...................#.........
 | 
				
			||||||
 | 
					#.#........###....#..........#.
 | 
				
			||||||
 | 
					.........#....#....#........##.
 | 
				
			||||||
 | 
					.#....#..#.........#..#........
 | 
				
			||||||
 | 
					...............#..#...#..#...##
 | 
				
			||||||
 | 
					.........#....##....#......#...
 | 
				
			||||||
 | 
					.#.............................
 | 
				
			||||||
 | 
					...#........#...#.#...#.#..#...
 | 
				
			||||||
 | 
					.....#..##...#.#...............
 | 
				
			||||||
 | 
					#.....#....#.........#.........
 | 
				
			||||||
 | 
					#...#...........##.........#...
 | 
				
			||||||
 | 
					..##........#.#...#...#......#.
 | 
				
			||||||
 | 
					...........#.....#...#.#.......
 | 
				
			||||||
 | 
					......###....#.....#...........
 | 
				
			||||||
 | 
					......##...#..........#....#.#.
 | 
				
			||||||
 | 
					.......##..##..........#.......
 | 
				
			||||||
 | 
					....#............#..#....##....
 | 
				
			||||||
 | 
					..##...................#.#.....
 | 
				
			||||||
 | 
					...#.#..#.#....................
 | 
				
			||||||
 | 
					.#..##..#............##.###..#.
 | 
				
			||||||
 | 
					#.#...#....#.#..........#.#....
 | 
				
			||||||
 | 
					........#....#.....#...........
 | 
				
			||||||
 | 
					..##....#...#.......#..........
 | 
				
			||||||
 | 
					...........##.##....#..........
 | 
				
			||||||
 | 
					.....#............#............
 | 
				
			||||||
 | 
					.......#.............#....#....
 | 
				
			||||||
 | 
					.................#......#......
 | 
				
			||||||
 | 
					......##.......#....#..##...#..
 | 
				
			||||||
 | 
					.#..#....#.....................
 | 
				
			||||||
 | 
					...#.#.#...#......##...........
 | 
				
			||||||
 | 
					##........##.#....#....#.......
 | 
				
			||||||
 | 
					.......#.....#..#..#...#.##....
 | 
				
			||||||
 | 
					#..........#....#.#..#..#..#...
 | 
				
			||||||
 | 
					...##..............#...........
 | 
				
			||||||
 | 
					.........#.....#.#....#.......#
 | 
				
			||||||
 | 
					.........#....##..#..##..#.....
 | 
				
			||||||
 | 
					.....#......................#..
 | 
				
			||||||
 | 
					...###...#..#......#...........
 | 
				
			||||||
 | 
					....#.....................#....
 | 
				
			||||||
 | 
					...............................
 | 
				
			||||||
 | 
					..#.....###.......#..#....#....
 | 
				
			||||||
 | 
					#..........#.................#.
 | 
				
			||||||
 | 
					......#.......###.......#..##..
 | 
				
			||||||
 | 
					.............#.##..............
 | 
				
			||||||
 | 
					......#..#.#..#...........#....
 | 
				
			||||||
 | 
					...#....##.#...#..#.#...#....#.
 | 
				
			||||||
 | 
					..................#...#....#.##
 | 
				
			||||||
 | 
					......#.#....#.................
 | 
				
			||||||
 | 
					......#.#.....#.....#..##......
 | 
				
			||||||
 | 
					#..##...........#..#.....#.##..
 | 
				
			||||||
							
								
								
									
										43
									
								
								day3/test_day3.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								day3/test_day3.py
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,43 @@
 | 
				
			||||||
 | 
					#! /usr/bin/env python3
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import pathlib
 | 
				
			||||||
 | 
					import pytest
 | 
				
			||||||
 | 
					import day3 as aoc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					PUZZLE_DIR = pathlib.Path(__file__).parent
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#these test fixtures setup the test, mainly by reading the filename into a string in this simple case.
 | 
				
			||||||
 | 
					@pytest.fixture
 | 
				
			||||||
 | 
					def example1():
 | 
				
			||||||
 | 
					    puzzle_input = (PUZZLE_DIR / "example1").read_text().strip()
 | 
				
			||||||
 | 
					    return aoc.parse(puzzle_input)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@pytest.fixture
 | 
				
			||||||
 | 
					def example2():
 | 
				
			||||||
 | 
					    puzzle_input = (PUZZLE_DIR / "example1").read_text().strip()
 | 
				
			||||||
 | 
					    return aoc.parse(puzzle_input)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# @pytest.mark.skip(reason="Not implemented")
 | 
				
			||||||
 | 
					def test_parse_example1(example1):
 | 
				
			||||||
 | 
					    """Test that input is parsed properly"""
 | 
				
			||||||
 | 
					    assert example1 == [[False, False, True, True, False, False, False, False, False, False, False],
 | 
				
			||||||
 | 
					            [True, False, False, False, True, False, False, False, True, False, False],
 | 
				
			||||||
 | 
					            [False, True, False, False, False, False, True, False, False, True, False],
 | 
				
			||||||
 | 
					            [False, False, True, False, True, False, False, False, True, False, True],
 | 
				
			||||||
 | 
					            [False, True, False, False, False, True, True, False, False, True, False],
 | 
				
			||||||
 | 
					            [False, False, True, False, True, True, False, False, False, False, False],
 | 
				
			||||||
 | 
					            [False, True, False, True, False, True, False, False, False, False, True],
 | 
				
			||||||
 | 
					            [False, True, False, False, False, False, False, False, False, False, True],
 | 
				
			||||||
 | 
					            [True, False, True, True, False, False, False, True, False, False, False],
 | 
				
			||||||
 | 
					            [True, False, False, False, True, True, False, False, False, False, True],
 | 
				
			||||||
 | 
					            [False, True, False, False, True, False, False, False, True, False, True]]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# @pytest.mark.skip(reason="Not implemented")
 | 
				
			||||||
 | 
					def test_part1_example1(example1):
 | 
				
			||||||
 | 
					    """Test part 1 on example input"""
 | 
				
			||||||
 | 
					    assert aoc.part1(example1) == 7
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# @pytest.mark.skip(reason="Not implemented")
 | 
				
			||||||
 | 
					def test_part2_example2(example2):
 | 
				
			||||||
 | 
					    """Test part 2 on example input"""
 | 
				
			||||||
 | 
					    assert aoc.part2(example2) == 336
 | 
				
			||||||
| 
						 | 
					@ -4,8 +4,9 @@ import pathlib
 | 
				
			||||||
import sys
 | 
					import sys
 | 
				
			||||||
import re
 | 
					import re
 | 
				
			||||||
from dataclasses import dataclass
 | 
					from dataclasses import dataclass
 | 
				
			||||||
 | 
					from pprint import pprint
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def parse(puzzle_input):
 | 
					def parse(puzzle_input: str):
 | 
				
			||||||
    """Parse input"""
 | 
					    """Parse input"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def part1(data):
 | 
					def part1(data):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue