Skip to content

Instantly share code, notes, and snippets.

@rtt
Last active December 12, 2022 13:39
Show Gist options
  • Save rtt/ba82379810bb21d3dbcaee77798a0011 to your computer and use it in GitHub Desktop.
Save rtt/ba82379810bb21d3dbcaee77798a0011 to your computer and use it in GitHub Desktop.
def partN(input_data, step):
for i, window in enumerate(
[input_data[i:i + step] for i in range(len(input_data) - step)]):
if len(set(window)) == step:
return i + step
if __name__ == '__main__':
with open('./input.txt') as f:
inp = f.read().strip()
print(partN(inp, 4))
print(partN(inp, 14))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment