| Total Complexity | 3 | 
| Total Lines | 22 | 
| Duplicated Lines | 0 % | 
| Changes | 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 |