Ejemplo n.º 1
0
def test_get_ints():
    inp = Input(IFILE, ["""123
456
7
0
"""])
    inp.use_test(0)
    i = inp.get_ints()
    assert(len(i) == 4)
    assert(i == [123, 456, 7, 0])
Ejemplo n.º 2
0
def test_read_file():
    inp = Input(IFILE)
    ints = inp.get_ints()
    assert(len(ints) == 200)
    assert(ints[0] == 1918)
    assert(ints[-1] == 1407)
Ejemplo n.º 3
0
7
9
4
2
34
10
3
"""
])

# inp.use_test(0)
# exp = 7 * 5
# inp.use_test(1)
# exp = 22 * 10

nums = sorted(inp.get_ints())
out = nums[-1] + 3
print(f"Device joltage: {out}")
anums = [0] + nums + [out]

ones = 0
threes = 0

for i, n in enumerate(anums[:-1]):
    x = anums[i + 1]
    d = x - n
    assert (d > 0 and d < 4)
    if d == 1:
        ones += 1
    elif d == 3:
        threes += 1