Esempio n. 1
0
def run():
    recipes = Recipes([3, 7], 0, 1)

    number = load_input_as_string(
        os.path.join(os.path.dirname(__file__), 'input.txt'))

    return recipes.get_total_recipes_before(number)
Esempio n. 2
0
def run():
    track = Track.parse(
        load_input_as_string(os.path.join(os.path.dirname(__file__),
                                          'input.txt'),
                             trim=False))

    return track.find_first_collision()
Esempio n. 3
0
def run():
    serial_number = int(
        load_input_as_string(
            os.path.join(os.path.dirname(__file__), 'input.txt')))

    grid = Grid(serial_number)

    return '(%d,%d) = %d' % grid.largest_power_grid(3)
Esempio n. 4
0
def run():
    recipes = Recipes([3, 7], 0, 1)

    number = int(
        load_input_as_string(
            os.path.join(os.path.dirname(__file__), 'input.txt')))

    return recipes.get_following_10_scores_after(number)
Esempio n. 5
0
def run():
    data = [
        int(d) for d in load_input_as_string(
            os.path.join(os.path.dirname(__file__), 'input.txt')).split(' ')
    ]

    tree = Node.load(data)

    return tree.calculate_checksum()
Esempio n. 6
0
def run():
    data = load_input_as_string(os.path.join(os.path.dirname(__file__), 'input.txt'))
    pattern = compile(r'^(?P<players>\d+) players; last marble is worth (?P<points>\d+) points$')
    match = pattern.match(data)
    players = int(match.group('players'))
    points = int(match.group('points'))

    game = Game(players, points)

    return game.get_highest_score()
Esempio n. 7
0
def run():
    s = load_input_as_string(
        os.path.join(os.path.dirname(__file__), 'input.txt'))
    shortest_length = len(s)
    for c in ascii_lowercase:
        length = len(reduce(remove_units(s, c)))
        if length < shortest_length:
            shortest_length = length

    return shortest_length
Esempio n. 8
0
def run():
    zone = Zone.parse(load_input_as_string(os.path.join(os.path.dirname(__file__), 'input.txt')))

    return zone.part1()
Esempio n. 9
0
def run():
    value = load_input_as_string(
        os.path.join(os.path.dirname(__file__), 'input.txt'))
    return len(reduce(value))