Created
December 6, 2022 06:43
-
-
Save ItsCalebJones/0d45c362ed7deb3957b0c1142363ff7e to your computer and use it in GitHub Desktop.
Day 6 - Advent of Code 2022
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from utils import get_inputs | |
from collections import Counter | |
def part_one(): | |
input = get_inputs(puzzle_day=6) | |
buffer_size = 4 | |
for i in range(len(input) - buffer_size + 1): | |
_string = (input[i: i + buffer_size]) | |
_counter = Counter(_string) | |
if len(_counter) == buffer_size: | |
return i + buffer_size | |
def part_two(): | |
input = get_inputs(puzzle_day=6) | |
buffer_size = 14 | |
for i in range(len(input) - buffer_size + 1): | |
_string = (input[i: i + buffer_size]) | |
_counter = Counter(_string) | |
if len(_counter) == buffer_size: | |
return i + buffer_size | |
if __name__ == '__main__': | |
start = time.perf_counter() | |
print(part_one()) | |
print(part_two()) | |
end = time.perf_counter() | |
print(f"Time to complete = {str((end - start) * 1000)} milliseconds.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment