예제 #1
0
def main():
    ''' main()

        Main function that use the input from Advent of Code and print the
        answer for day threes problem.
    '''
    print(distance(aoc_03_input.get_input()))
예제 #2
0
def test_task1():
    (aoc_input,
     potential_non_overlapping_claims) = aoc_03_input.get_input('test_input')

    expected = 4
    actual = aoc_03.solve_task_1(aoc_input)

    assert actual == expected
예제 #3
0
def main():
    ''' main()

        Main function that use the input from Advent of Code and print the
        answer for day threes problem.
    '''
    target = aoc_03_input.get_input()

    # The square we want will always be in a square earlier than the target
    # value
    for square in generate_spiral(target):
        if square['value'] > target:
            print(square['value'])
            break
예제 #4
0
def main():
    """ main()

        Main function that use the input from Advent of Code and print the
        answer to the problems for day one.
    """
    aoc_input = aoc_03_input.get_input()

    total_triangles_possible = calculate_number_of_possible_triangles(
        aoc_input)
    total_triangles_possible_task2 = calculate_number_of_possible_triangles_task2(
        aoc_input)

    print('Part 1: {}'.format(total_triangles_possible))
    print('Part 2: {}'.format(total_triangles_possible_task2))
예제 #5
0
def main():
    """ main()

        Main function used to solve the problem for day 3. Actually, much work is done by aoc_03_input for this day.
        It gives a dict with claims, where the keys are (x, y)-coordinates. This functions loops over all coordinates
        to check which ones are overlapping or not. We also get a list of all claim-id's, so that we can find out
        which one is not conflicting with another claim id.
    """
    (aoc_input,
     potential_non_overlapping_claims) = aoc_03_input.get_input('input')

    number_of_overlaps = solve_task_1(aoc_input)
    non_overlapping_claim = solve_task_2(aoc_input,
                                         potential_non_overlapping_claims)

    print('Part 1: {}'.format(number_of_overlaps))
    print('Part 2: {}'.format(non_overlapping_claim))
예제 #6
0
def main():
    (part_2, part_1) = calculate_overlapping_squares(aoc_03_input.get_input())

    print(f"Advent of Code 2018 day 3 part 1: {part_1}")
    print(f"Advent of Code 2018 day 3 part 2: {part_2}")