Пример #1
0
        # first command - OP code
        op_code = command[0]
        if op_code == 99:
            break
        elif op_code == 1:
            add = True
        elif op_code == 2:
            add = False

        # second and third command - values based on indexes given by the commands are either added or multiplied
        first_num = inp_list[command[1]]
        second_num = inp_list[command[2]]

        if add:
            command_result = first_num + second_num
        else:
            command_result = first_num * second_num

        # fourth command - memory location in which to save the result
        inp_list[command[3]] = command_result

    return inp_list


aoc_data = AOC.get_data(2)
result = get_solution(aoc_data)
print(result)

AOC.submit(data=result[0], part='a', day=2)
Пример #2
0
        # first command - OP code
        op_code = command[0]
        if op_code == 99:
            break
        elif op_code == 1:
            add = True
        elif op_code == 2:
            add = False

        # second and third command - values based on indexes given by the commands are either added or multiplied
        first_num = inp_list[command[1]]
        second_num = inp_list[command[2]]

        if add:
            command_result = first_num + second_num
        else:
            command_result = first_num * second_num

        # fourth command - memory location in which to save the result
        inp_list[command[3]] = command_result

    return inp_list


aoc_data = AOC.get_data(2)
solution = get_solution(aoc_data)

result = 100 * solution[1] + solution[2]
AOC.submit(data=result, part='b', day=2)
Пример #3
0
from aoc import AOC


def get_solution(inp: str):
    mass_data = [int(item) for item in inp.split('\n')]
    fuel_data = [(mass // 3) - 2 for mass in mass_data]
    total_fuel = sum(fuel_data)
    return total_fuel


aoc_data = AOC.get_data(1)
result = get_solution(aoc_data)

AOC.submit(data=result, part='a', day=1)
Пример #4
0
from aoc import AOC
from year_20.day_13.solution_b import get_solution

day = 13
part = "b"

aoc_data = AOC.get_data(day=day, year=2020)
result = get_solution(aoc_data)
print(result)
AOC.submit(data=result, part=part, day=day, year=2020)