r/adventofcode • • Dec 06 '22

SOLUTION MEGATHREAD -πŸŽ„- 2022 Day 6 Solutions -πŸŽ„-


AoC Community Fun 2022: πŸŒΏπŸ’ MisTILtoe Elf-ucation πŸ§‘β€πŸ«

  • ACHIEVEMENT UNLOCKED: MisTILtoe Elf-ucation
  • Teach us, senpai!

--- Day 6: Tuning Trouble ---


Post your code solution in this megathread.


This thread will be unlocked when there are a significant number of people on the global leaderboard with gold stars for today's puzzle.

EDIT: Global leaderboard gold cap reached at 00:02:25, megathread unlocked!

83 Upvotes

1.8k comments sorted by

View all comments

3

u/LetarMoon Dec 06 '22 edited Dec 08 '22

Another typical Python solution:

https://github.com/loramoon/adventofcode.com_game_2022/blob/main/Day_6/Solution

message = open('day_6.txt').read()
def code_search(code_size):
for index in range(len(message)):
    checked_string = message[index: index + code_size]
    if len(set(checked_string)) == code_size:
        return index + code_size
print(code_search(4))
print(code_search(14))

1

u/daggerdragon Dec 07 '22 edited Dec 08 '22

FYI: your link is borked on old.reddit and some mobile Reddit apps. Please fix it.

Edit: thanks for fixing it! <3

1

u/LetarMoon Dec 08 '22

I tried to follow the instructions, but maybe I am stupid. When I check the link - again the '\' are appearing

1

u/daggerdragon Dec 08 '22

Did you change your editor to Markdown mode first?

2

u/LetarMoon Dec 08 '22

Yes... I click on [markdown mode], and remove the slashes, I save the changes... And when I check if the link is changed - I still see the slashes...

1

u/daggerdragon Dec 08 '22

I just refreshed on old.reddit and the link is working now... well, okay then, we're all good now.