Example #1
0
        llist[input_seq[i]] = input_seq[i + 1]
    llist[input_seq[-1]] = input_seq[0]

    current_cup = input_seq[0]
    # pprint(llist)
    for i in range(move_count):
        llist, current_cup = llist_move(llist, current_cup, 1, input_max)

    a = llist[1]
    b = llist[a]

    return a, b, a * b


"""
Use script args to execute the right function.
"""
if __name__ == '__main__':
    if len(sys.argv) > 1 and sys.argv[1] == '1':
        res = solve1((Input(DAY).read()))
        print(res)
    if len(sys.argv) > 1 and sys.argv[1] == '1t':
        res = solve1((test_input(DAY).read()))
        print(res)
    if len(sys.argv) > 1 and sys.argv[1] == '2':
        res = solve2((Input(DAY).read()))
        print(res)
    if len(sys.argv) > 1 and sys.argv[1] == '2t':
        res = solve2((test_input(DAY).read()))
        print(res)
Example #2
0
    for i in range(0, len(data)):
        dsum = 0
        subset = []
        for j in range(i, len(data)):
            dsum += data[j]
            subset.append(data[j])
            if len(subset) == 1:
                continue
            if dsum > target:
                break
            if dsum == target:
                return min(subset) + max(subset)


"""
Use script args to execute the right function.
"""
if __name__ == '__main__':
    if len(sys.argv) > 1 and sys.argv[1] == '1':
        res = solve1((Input(DAY).readlines()), 25)
        print(res)
    if len(sys.argv) > 1 and sys.argv[1] == '1t':
        res = solve1((test_input(DAY).readlines()), 5)
        print(res)
    if len(sys.argv) > 1 and sys.argv[1] == '2':
        res = solve2((Input(DAY).readlines()), 25)
        print(res)
    if len(sys.argv) > 1 and sys.argv[1] == '2t':
        res = solve2((test_input(DAY).readlines()), 5)
        print(res)