Ejemplo n.º 1
0
def __main():
    with localtimer():
        res = decode2('12432111221121211222121122212')
        # res = decode2('1212')
    with localtimer():
        print(len(res))
    with localtimer():
        print(len(res.strings))
Ejemplo n.º 2
0
def __main():
    with U.localtimer():
        print(aoc4(has_double, is_monotonic))
    with U.localtimer():
        print(aoc4_faster_on_more_than_one_validator(has_double, is_monotonic))
    with U.localtimer():
        print(aoc4(has_exact_double))
    with U.localtimer():
        print(aoc4_faster_on_more_than_one_validator(has_exact_double))
Ejemplo n.º 3
0
def __main():
    # s = 'abcdefghijklmnop'
    # for i in range(4, 11):
    #     print(s[:i])
    #     with localtimer():
    #         print(len(list(permutations(s[:i]))))
    #     with localtimer():
    #         perms_unique(set(s[:i]))
    #     print(30 * '=')

    s = 'aaabb'
    with localtimer():
        print(len(list(permutations(s))))
    with localtimer():
        print(perms_with_dupes(s))
    print(30 * '=')
Ejemplo n.º 4
0
def __main():
    init_state, state_map = init_state_and_state_map()
    print(part1(init_state, state_map))
    with localtimer():
        print('===============')
        print(part2(init_state, state_map))
    print(50000000000 - 50_000_000_000)
Ejemplo n.º 5
0
def __main():
    insts = first(read_file(16, 2017)).split(',')
    for dc in Dance, DanceList, DanceStr:
        print(dc)
        with localtimer():
            print(part1(insts, dc))
            print(part2(insts, dc))
        print()
Ejemplo n.º 6
0
def __main():
    strs = U.read_file(24, 2017)
    comps = [Comp.from_str(s) for s in strs]
    comp_map = CompMap.from_comps(comps)

    with U.localtimer():
        print(calc_longest_bridge(comp_map, maxkey=itemgetter(1)))
        print(calc_longest_bridge(comp_map, maxkey=U.identity))
Ejemplo n.º 7
0
def __main():
    comps = [Comp.from_str(s) for s in read_file(24, 2017)]
    # comps = [Comp(0, 2), Comp(2, 2), Comp(2, 2)]
    cm = CompMap()
    for c in comps:
        cm.add(c)
    with localtimer():
        print(calc_strongest_bridge(cm))
        print(calc_strongest_bridge(cm, lambda x: x))
Ejemplo n.º 8
0
def part1(fname=None):
    m = Map(fname)
    t = m.tick()
    with localtimer():
        rnd_num, remaining_hp = last(t)
    # hack for off by 1 error on big input...
    if not fname:
        rnd_num -= 1

    m.display()
    print(rnd_num, remaining_hp)
    return rnd_num * remaining_hp
Ejemplo n.º 9
0
def __main():
    size = 4500
    # with localtimer():
    #     r1 = take(size, _yield_mults2())
    with localtimer():
        ym3 = _yield_mults3()
        for _ in range(size):
            r2 = next(ym3)
    print(r2)
    return
    # print(get_kth(5))
    # return
    t = _yield_mults2()
    res = []
    for _ in range(1000):
        res.append(next(t))
    for i, (v1, v2) in enumerate(zip(kth_multiple(1000)[1], res)):
        if v1 != v2:
            print(i, v1, v2)
Ejemplo n.º 10
0
def __main():
    with localtimer():
        print(short_sub2([2, -1, 2], 3))
        print(short_sub2([1, 2], 4))
        print(short_sub2([1], 1))
        print(shortestSubarray(n_test, 5))
Ejemplo n.º 11
0
def __main():
    with localtimer():
        print(part1())
        print(part2())
Ejemplo n.º 12
0
def __main():
    # with localtimer():
    #     print(aoc05_a())
    with localtimer():
        print(aoc05_b())
Ejemplo n.º 13
0
def __main():
    with U.localtimer():
        print(aoc15(a_mult=1, b_mult=1))
    with U.localtimer():
        print(aoc15(n=5_000_000))
Ejemplo n.º 14
0
def __main():
    print(part1())
    with localtimer():
        print(part2_smart())
Ejemplo n.º 15
0
def __main():
    with U.localtimer():
        # print(calc_steps2(Maze.from_file('18.test1')))
        # print(calc_steps2(Maze.from_file('18.test2')))
        print(calc_steps2(Maze.from_file('18.test3')))
Ejemplo n.º 16
0
def __main():
    with localtimer():
        print(run(int(1e9)))
Ejemplo n.º 17
0
def __main():
    data = parse_data(U.read_file(13, 2017))
    print(sum(starmap(mul, calc_detections(data))))
    with U.localtimer():
        print(delay(data))
Ejemplo n.º 18
0
def __main():
    sm = StateMachine(parse_data(25))
    with U.localtimer():
        sm.run()
    print(sm.checksum)
Ejemplo n.º 19
0
def __main():
    data = parse_data(U.read_file(12, 2017))
    with U.localtimer():
        print(aoc12_a(data))
        print(get_num_distinct_groups(data))
Ejemplo n.º 20
0
# print(f.getIndex(0))
# f.multAll(2)
# print(f.getIndex(0))
#
# with localtimer():
#     for _ in range(100):
#         f = Fancy()
#         f.append(8, )
#         (f.getIndex(0, ))
#         for _ in range(1000):
#             f.multAll(7, )
#             f.addAll(2)
#             f.append(5, )
#             (f.getIndex(0, ))
#         f.append(3, )
#         f.addAll(6, )
#         (f.getIndex(0, ))
#     print(f.getIndex(32))

f = Fancy()
with localtimer():
    run(f, '/tmp/in', do_print=True)


def __main():
    pass


if __name__ == '__main__':
    __main()
Ejemplo n.º 21
0
def __main():
    insts = read_file(12, 2016)
    with localtimer():
        print(aoc12(insts))
    with localtimer():
        print(aoc12(insts, c=1))
Ejemplo n.º 22
0
def __main():
    with U.localtimer():
        print(aoc21())
    with U.localtimer():
        print(aoc21(18))
Ejemplo n.º 23
0
def __main():
    max_size = 2 ** 20
    with localtimer():
        n = short_tree(list(range(max_size)))
    print(find_common2(n, 1, max_size - 1))
    pass
Ejemplo n.º 24
0
def __main():
    print(aoc17_a())
    with U.localtimer():
        print(aoc17_b())