Ejemplo 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)
Ejemplo 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()
Ejemplo 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)
Ejemplo 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)
Ejemplo 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()
Ejemplo 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()
Ejemplo 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
Ejemplo n.º 8
0
def run():
    zone = Zone.parse(load_input_as_string(os.path.join(os.path.dirname(__file__), 'input.txt')))

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