Пример #1
0
def __main():
    with localtimer():
        res = decode2('12432111221121211222121122212')
        # res = decode2('1212')
    with localtimer():
        print(len(res))
    with localtimer():
        print(len(res.strings))
Пример #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))
Пример #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 * '=')
Пример #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)
Пример #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()
Пример #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))
Пример #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))
Пример #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
Пример #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)
Пример #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))
Пример #11
0
def __main():
    with localtimer():
        print(part1())
        print(part2())
Пример #12
0
def __main():
    # with localtimer():
    #     print(aoc05_a())
    with localtimer():
        print(aoc05_b())
Пример #13
0
def __main():
    with U.localtimer():
        print(aoc15(a_mult=1, b_mult=1))
    with U.localtimer():
        print(aoc15(n=5_000_000))
Пример #14
0
def __main():
    print(part1())
    with localtimer():
        print(part2_smart())
Пример #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')))
Пример #16
0
def __main():
    with localtimer():
        print(run(int(1e9)))
Пример #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))
Пример #18
0
def __main():
    sm = StateMachine(parse_data(25))
    with U.localtimer():
        sm.run()
    print(sm.checksum)
Пример #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))
Пример #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()
Пример #21
0
def __main():
    insts = read_file(12, 2016)
    with localtimer():
        print(aoc12(insts))
    with localtimer():
        print(aoc12(insts, c=1))
Пример #22
0
def __main():
    with U.localtimer():
        print(aoc21())
    with U.localtimer():
        print(aoc21(18))
Пример #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
Пример #24
0
def __main():
    print(aoc17_a())
    with U.localtimer():
        print(aoc17_b())