Skip to content

Instantly share code, notes, and snippets.

@rtt
Last active December 12, 2022 13:39
Show Gist options
  • Select an option

  • Save rtt/ba82379810bb21d3dbcaee77798a0011 to your computer and use it in GitHub Desktop.

Select an option

Save rtt/ba82379810bb21d3dbcaee77798a0011 to your computer and use it in GitHub Desktop.
def partN(input_data, step):
i = 0
while True:
chunk = input_data[i:step + i]
if not len(chunk) == step:
# reached end
break
if len(set(chunk)) == step:
return i + step
i += 1
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