[py] Solve 2022_06
This commit is contained in:
parent
5e92bddc15
commit
fa688258ca
2 changed files with 11 additions and 1 deletions
|
|
@ -4,7 +4,7 @@ from pathlib import Path
|
|||
|
||||
from .y2020 import d10
|
||||
from .y2021 import d14
|
||||
from .y2022 import d01, d02, d03, d04, d05
|
||||
from .y2022 import d01, d02, d03, d04, d05, d06
|
||||
|
||||
DAYS = {
|
||||
"2020_10": y2020.d10.solve,
|
||||
|
|
@ -14,6 +14,7 @@ DAYS = {
|
|||
"2022_03": y2022.d03.solve,
|
||||
"2022_04": y2022.d04.solve,
|
||||
"2022_05": y2022.d05.solve,
|
||||
"2022_06": y2022.d06.solve,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
9
py/aoc/y2022/d06.py
Normal file
9
py/aoc/y2022/d06.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
def scan(s, lookback):
|
||||
for i in range(len(s) - lookback + 1):
|
||||
if len(set(s[i : i + lookback])) == lookback:
|
||||
return i + lookback
|
||||
|
||||
|
||||
def solve(inputstr):
|
||||
print(f"Part 1: {scan(inputstr, 4)}")
|
||||
print(f"Part 2: {scan(inputstr, 14)}")
|
||||
Loading…
Add table
Add a link
Reference in a new issue