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

main   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 16
dl 0
loc 22
rs 10
c 0
b 0
f 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A main() 0 4 1
A get_first_non_repeating() 0 8 2
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