Beispiel #1
0
def part1():
    codes = get_lines('day5.input')
    high = 0
    for code in codes:
        if high < calculate_seat_id(code):
            high = calculate_seat_id(code)
    print('high is {}'.format(high))
Beispiel #2
0
def part1():
    entries = get_lines('day2.input')
    num_valid = 0;
    for entry in entries:
        if (is_valid(entry)):
            num_valid = num_valid + 1
    print('number of valid passes: {}'.format(num_valid))
Beispiel #3
0
def part1():
    entries = get_lines('day1.input')
    for i in range(len(entries)):
        entries[i] = int(entries[i])
    addends_of_2020 = get_addends_of_2020(entries)
    print("{} + {} = {}".format(addends_of_2020[0], addends_of_2020[1],
                                addends_of_2020[0] + addends_of_2020[1]))
    print("{} x {} = {}".format(addends_of_2020[0], addends_of_2020[1],
                                addends_of_2020[0] * addends_of_2020[1]))
Beispiel #4
0
 def test_part1(self):
     test_input = [
         'abc', '', 'a', 'b', 'c', '', 'ab', 'ac', '', 'a', 'a', 'a', 'a',
         '', 'b', ''
     ]
     assert_with_message(6, get_total(test_input))
     assert_with_message(3435, get_total(get_lines('day6.input') + ['']))
     assert_with_message(3435, get_total(get_input(6)))
     part2()
Beispiel #5
0
def part2():
    codes = get_lines('day5.input')
    seatmap = generate_seatmap()
    for code in codes:
        mark_seatmap(seatmap, code)
    for row in range(len(seatmap)):
        for column in range(len(seatmap[row])):
            if seatmap[row][column] == 0 and is_my_seat(seatmap, row, column):
                print('my seat is row {} column {}.'.format(row, column))
Beispiel #6
0
 def test_part1(self):
     test_input = [
         'abc', '', 'a', 'b', 'c', '', 'ab', 'ac', '', 'a', 'a', 'a', 'a',
         '', 'b'
     ]
     assert_with_message(11, get_total(test_input))
     assert_with_message(6714, get_total(get_lines('day6.input')))
     assert_with_message(6714, get_total(get_input(6)))
     part1()
Beispiel #7
0
def part2():
    entries = get_lines('day1.input')
    addends_of_2020 = get_addends_of_2020(entries)
    print("{} + {} + {} = {}".format(
        addends_of_2020[0], addends_of_2020[1], addends_of_2020[2],
        addends_of_2020[0] + addends_of_2020[1] + addends_of_2020[2]))
    print("{} + {} + {} = {}".format(
        addends_of_2020[0], addends_of_2020[1], addends_of_2020[2],
        addends_of_2020[0] * addends_of_2020[1] * addends_of_2020[2]))
Beispiel #8
0
 def test_part2(self):
     test_input = [
         '..##.......', '#...#...#..', '.#....#..#.', '..#.#...#.#',
         '.#...##..#.', '..#.##.....', '.#.#.#....#', '.#........#',
         '#.##...#...', '#...##....#', '.#..#...#.#'
     ]
     assert_with_message(7, count_trees(test_input, 3))
     assert_with_message(336, combine_paths(test_input))
     map_lines = get_lines('day3.input')
     assert_with_message(211, count_trees(map_lines, 3))
     part2()
Beispiel #9
0
def part1():
    print(count_trees(get_lines('day3.input'), 3))
Beispiel #10
0
def part1():
    passport_data = get_lines('day4.input')
    print('number of valid passports: {}'.format(
        find_number_of_valid_passports(passport_data)))
Beispiel #11
0
def part2():
    print(get_total(get_lines('day6.input')))
Beispiel #12
0
def part2():
    map_lines = get_lines('day3.input')
    print('result: {}'.format(combine_paths(map_lines)))