def test(): vals = read_file("test_input.txt") assert part1(vals) == 26 print("Passed Part 1") mapping_in = "acedgfb cdfbe gcdfa fbcad dab cefabd cdfgeb eafb cagedb ab".split( ) mapping = { "a": "d", "b": "e", "c": "a", "d": "f", "e": "g", "f": "b", "g": "c" } assert determine_mapping(mapping_in) == mapping print("Passed mapping test") decode_test_values = {"cdfeb": 5, "fcadb": 3, "cdfeb": 5, "cdbaf": 3} decode_mapping = {mapping[key]: key for key in mapping} assert all( determine_output(val, decode_mapping) == decode_test_values[val] for val in decode_test_values) print("Passed output test") assert part2(vals) == 61229 print("Passed Part 2")
def test(): vals = read_file("test_input.txt") paper = Paper(vals[0]) for instruction in vals[1]: paper.fold(*instruction) assert str(paper) == "#####\n#...#\n#...#\n#...#\n#####\n.....\n....." print("Passed folding test")
def test(): vals = read_file("test_input.txt") assert part1(vals, days=18) == 26 assert part1(vals) == 5934 print("Passed Part 1") assert part2(vals) == 26984457539 print("Passed Part 2")
def test(): vals = read_file("test_input.txt") octopuses = create_octopuses(vals) flashes = 0 for _ in range(10): flashes += step(octopuses) assert flashes == 204 print("Passed Test with 10 Iterations") assert part1(vals) == 1656 print("Passed Part 1") assert part2(vals) == 195 print("Passed Part 2")
def test(): vals = read_file("test_input.txt") assert count(vals[0], vals[1], 1) == count_chars("NCNBCHB") assert count(vals[0], vals[1], 2) == count_chars("NBCCNBBBCBHCB") assert count(vals[0], vals[1], 3) == count_chars("NBBBCNCCNBBNBNBBCHBHHBCHB") assert count( vals[0], vals[1], 4) == count_chars("NBBNBNBBCCNBCNCCNBBNBBNBBBNBBNBBCBHCBHHNHCBBCBHCB") print("Passed Counting") elements = count(vals[0], vals[1], 10) assert elements == {"B": 1749, "C": 298, "H": 161, "N": 865} assert part1(*vals) == 1588 print("Passed Part 1") elements = count(vals[0], vals[1], 40) assert elements["B"] == 2192039569602 assert elements["H"] == 3849876073 assert part2(*vals) == 2188189693529 print("Passed Part 2")
def test(): vals = read_file("test_input.txt") assert part1(vals) == 26397 print("Passed Part 1") assert part2(vals) == 288957 print("Passed Part 2")
def test(): draws, fields = read_file("test_input.txt") assert part1(draws, fields) == 4512 print("Passed Part 1") assert part2(draws, fields) == 1924 print("Passed Part 2")
def test(): vals = read_file("test_input.txt") assert part1(vals) == 37 print("Passed Part 1") assert part2(vals) == 168 print("Passed Part 2")