Esempio n. 1
0
def day02_02():
    """Run part 2 of Day 1's code"""
    path = "./input/02/input.txt"
    common_letters = find_similar_boxids(file_to_str_array(path))
    print(f"Similar Characters: {common_letters}")
Esempio n. 2
0
 def test_run_6(self):
     mygame = Conway3D(file_to_str_array('tests/day17_testdata.txt'))        
     result=mygame.run(6)
     assert result == 112
Esempio n. 3
0
def day06_01():
    """Run part 1 of Day 06's code"""
    path = "./input/06/input.txt"
    result = count_uniq_questions(file_to_str_array(path))
    print(f'0601: The Sum of questions answer is: {result}')
Esempio n. 4
0
def day08_01():
    """Run part 1 of Day 08's code"""
    path = "./input/08/input.txt"
    mybootcode = BootCode(file_to_str_array(path))
    result = mybootcode.run()
    print(f'0801: Accumulator value on looping: {result}')
Esempio n. 5
0
def day10_02():
    """Run part 2 of Day 10's code"""
    path = "./input/10/input.txt"
    result = number_combinations(file_to_str_array(path))
    print(f'1002: The number of different ways we can power our laptop is: {result}')
Esempio n. 6
0
 def test_init_print(self):
     expected = 25
     testnavcomp = NavComp(file_to_str_array('tests/day12_testdata.txt'))
     result = testnavcomp.dist_from_origin()
     assert expected == result
Esempio n. 7
0
def day19_01():
    """Run part 1 of Day 19's code"""
    path = "./input/19/input.txt"
    mycomp = RegExpComputer(file_to_str_array(path))
    result = mycomp.match()
    print(f'1901: Number of messages that match: {result}')
Esempio n. 8
0
 def test_match(self):
     testdata = 'tests/day19_testdata2.txt'
     mycomp = RegExpComputerRecursive(file_to_str_array(testdata))
     result = mycomp.match()
     assert result == 12
Esempio n. 9
0
def day03_01():
    """Run part 1 of Day 3's code"""

    path = "./input/03/input.txt"
    myrun=ToboganRun(file_to_str_array(path))
    print(f'0301: Number of Trees Intercepted: {myrun.tree_count()}')
Esempio n. 10
0
def day16_01():
    """Run part 1 of Day 16's code"""
    path = "./input/16/input.txt"
    mytickets = Tickets(file_to_str_array(path))
    result = mytickets.ticket_scanning_error_rate()
    print(f'1601: Ticket scanning error rate is: {result}')
Esempio n. 11
0
def day12_02():
    """Run part 2 of Day 12's code"""
    path = "./input/12/input.txt"
    testnavcomp = NavCompPart2(file_to_str_array(path))
    result = testnavcomp.dist_from_origin()
    print(f'1202: Ship distance from origin using waypoints: {result}')
Esempio n. 12
0
def day12_01():
    """Run part 1 of Day 12's code"""
    path = "./input/12/input.txt"
    testnavcomp = NavComp(file_to_str_array(path))
    result = testnavcomp.dist_from_origin()
    print(f'1201: Ship distance from origin: {result}')
Esempio n. 13
0
 def test_run_1_4D(self):
     my4dgame = Conway4D(file_to_str_array('tests/day17_testdata.txt'))
     result = my4dgame.run(1)
     print(str(my4dgame))
     assert result == 29
Esempio n. 14
0
 def test_read_data_recursive(self):
     testdata = 'tests/day19_testdata2.txt'
     mycomp = RegExpComputerRecursive(file_to_str_array(testdata))
     assert (8, 11) == mycomp.rules[0]
     assert 'bbabbbbaabaabba' in mycomp.messages
Esempio n. 15
0
def day18_01():
    """Run part 1 of Day 18's code"""
    path = "./input/18/input.txt"
    result=sum([FunnyMath(inputeqn).run() for inputeqn in file_to_str_array(path)])
    print(f'1801: Sum of all problems in homework: {result}')
Esempio n. 16
0
 def test_read_data(self):
     testdata = 'tests/day19_testdata.txt'
     mycomp = RegExpComputer(file_to_str_array(testdata))
     assert (4, 1, 5) == mycomp.rules[0]
     assert 'aaaabbb' in mycomp.messages
Esempio n. 17
0
def day18_02():
    """Run part 2 of Day 18's code"""
    path = "./input/18/input.txt"
    result=sum([FunnyMath2(inputeqn).run() for inputeqn in file_to_str_array(path)])
    print(f'1802: Sum of all problems in homework with addition precedence: {result}')
Esempio n. 18
0
def day10_01():
    """Run part 1 of Day 10's code"""
    path = "./input/10/input.txt"
    result = jolt_diff_dist(file_to_str_array(path))
    print(f'1001: The product of 1 and 3 adapter differences is: {result}')
Esempio n. 19
0
 def processinputfile(self):
     self.input = file_to_str_array(self.inputfile)
Esempio n. 20
0
 def __init__(self, inputfile):
     self.inputdata = file_to_str_array(inputfile)
     self.read_rows()
     self.read_cols(self.rows)
Esempio n. 21
0
 def test_01(self):
     expected=6
     testinput=file_to_str_array("tests/day06_testinput.txt")
     result=count_all_answered_questions(testinput)
     assert result== expected
Esempio n. 22
0
 def test_turnright_part2(self):
     expected = 286
     testnavcomp = NavCompPart2(
         file_to_str_array('tests/day12_testdata.txt'))
     result = testnavcomp.dist_from_origin()
     assert result == expected
Esempio n. 23
0
 def test_(self):
     expected=11
     testinput=file_to_str_array("tests/day06_testinput.txt")
     print(testinput)
     result=count_uniq_questions(testinput)
     assert result == expected
Esempio n. 24
0
def day06_02():
    """Run part 2 of Day 06's code"""
    path = "./input/06/input.txt"
    result = count_all_answered_questions(file_to_str_array(path))
    print(f'0602: Sum of questions answered by all in the group: {result}')
Esempio n. 25
0
 def test_bags_in_our_bag2(self):
     testinput = file_to_str_array("tests/day07_testdata2.txt")
     mydict = build_dict(testinput)
     our_bag = {'shiny gold': 1}
     result = bags_in_our_bag(our_bag, mydict)
     assert result == 126
Esempio n. 26
0
def day02_01():
    """Run part 1 of Day 2's code"""
    path = "./input/02/input.txt"
    final_checksum = checksum_multiple_labels(file_to_str_array(path))
    print(f"final checksum: {final_checksum}")
Esempio n. 27
0
 def test_build_dict(self):
     testinput = file_to_str_array("tests/day07_testdata.txt")
     mydict = build_dict(testinput)
     assert mydict['dotted black'] == {}
     assert mydict['light red']['bright white'] == 1
Esempio n. 28
0
 def __init__(self,inputdata):
     ''' Initialise the computer and read in the instructions'''
     self.mask=''
     self.mem=defaultdict(int)
     self.inputdata=file_to_str_array(inputdata)
     self.intsize=36
Esempio n. 29
0
 def test_count_neighbours(self):
     mygame = Conway3D(file_to_str_array('tests/day17_testdata.txt'))        
     result=mygame.count_occupied((1,1,0))
     assert result == 5