Passed
Push — main ( 83fd9b...e71399 )
by Yohann
57s
created

main.main()   A

Complexity

Conditions 1

Size

Total Lines 4
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nop 0
1
import pathlib
2
3
4
def get_first_non_repeating(sequence: str, buffer_size: int) -> int:
5
    buf = [''] * buffer_size
6
    idx = 0
7
    while len(set(x for x in buf if x)) != buffer_size:
8
        buf.pop(0)
9
        buf.append(sequence[idx])
10
        idx += 1
11
    return idx
12
13
14
def main():
15
    content = pathlib.Path('./input.txt').read_text()
16
    print('Part 1:', get_first_non_repeating(content, 4))
17
    print('Part 2:', get_first_non_repeating(content, 14))
18
19
20
if __name__ == '__main__':
21
    main()
22