示例#1
0
def calculate() -> int:
    total = 0
    lines = read_file()
    for mass in lines.splitlines():
        total += (int(mass) // 3) - 2

    return total
示例#2
0
def calculate():
    lines = read_file()
    wires = lines.splitlines()
    path_one = construct_wire(wires[0].split(','))
    path_two = construct_wire(wires[1].split(','))

    intersections = find_intersections(path_one, path_two)
    return closest_distance_to_starting(intersections)
示例#3
0
def calculate() -> int:
    total = 0
    lines = read_file()
    for mass in lines.splitlines():
        current_total = 0
        fuel_needed = calculate_single(mass)
        while fuel_needed > 0:
            current_total += fuel_needed
            fuel_needed = calculate_single(fuel_needed)

        total += current_total

    return total
示例#4
0
def calculate():
    lines = read_file()
    wires = lines.splitlines()
    path_one = construct_wire(wires[0].split(','))
    path_two = construct_wire(wires[1].split(','))

    intersections = find_intersections(path_one, path_two)
    steps = []
    for intersection in intersections:
        steps_one = find_num_of_steps(path_one, intersection)
        steps_two = find_num_of_steps(path_two, intersection)
        steps.append(steps_one + steps_two)

    return min(steps)
示例#5
0
def calculate() -> int:
    line = read_file()
    str_codes = line.split(',')
    int_codes = [int(s) for s in str_codes]

    noun = -1
    verb = -1

    for x in range(0, 100):
        for j in range(0, 100):
            temp_copy = copy(int_codes)
            temp_copy[1] = x
            temp_copy[2] = j
            result = process_instructions(temp_copy)[0]

            if result == 19690720:
                noun = x
                verb = j
                break

    return 100 * noun + verb