cleaned up templates.
This commit is contained in:
		
							parent
							
								
									7fd7d753bb
								
							
						
					
					
						commit
						fdbc386511
					
				
					 6 changed files with 68 additions and 4 deletions
				
			
		
							
								
								
									
										30
									
								
								day1/day1.py
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										30
									
								
								day1/day1.py
									
										
									
									
									
										Executable file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,30 @@
 | 
			
		|||
#! /usr/bin/env python3
 | 
			
		||||
 | 
			
		||||
import pathlib
 | 
			
		||||
import sys
 | 
			
		||||
# import parse
 | 
			
		||||
 | 
			
		||||
def parse(puzzle_input):
 | 
			
		||||
    """Parse input"""
 | 
			
		||||
 | 
			
		||||
def part1(data):
 | 
			
		||||
    """Solve part 1"""
 | 
			
		||||
 | 
			
		||||
def part2(data):
 | 
			
		||||
    """Solve part 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()
 | 
			
		||||
        print(f'{puzzle_input}')
 | 
			
		||||
        solutions = solve(puzzle_input)
 | 
			
		||||
        print("\n".join(str(solution) for solution in solutions))
 | 
			
		||||
							
								
								
									
										33
									
								
								day1/test_day1.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								day1/test_day1.py
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,33 @@
 | 
			
		|||
#! /usr/bin/env python3
 | 
			
		||||
 | 
			
		||||
import pathlib
 | 
			
		||||
import pytest
 | 
			
		||||
import template 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 / "example2").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 == ...
 | 
			
		||||
 | 
			
		||||
@pytest.mark.skip(reason="Not implemented")
 | 
			
		||||
def test_part1_example1(example1):
 | 
			
		||||
    """Test part 1 on example input"""
 | 
			
		||||
    assert aoc.part1(example1) == ...
 | 
			
		||||
 | 
			
		||||
@pytest.mark.skip(reason="Not implemented")
 | 
			
		||||
def test_part2_example2(example2):
 | 
			
		||||
    """Test part 2 on example input"""
 | 
			
		||||
    assert aoc.part2(example2) == ...
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue