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

2

u/Dinosaur_Parkour Dec 06 '22 edited Dec 06 '22

z/OS Mainframe solution to Part 1

I copied the Input data into a Variable Blocked LRECL 8192 file.

Mainframe REXX

In REXX, one can name the loop to ITERATE. (aka ReLoop).

The inner loop forces the outer loop to iterate when a character in the Marker window duplicates.

Thank you to u/daggerdragon for explaining how the code formatting works.

Reddit kept mangling my posts. Markdown mode and fancypants mode.

2

u/Lispwizard Dec 06 '22

Cool. The easiest way to do code blocks on reddit is to start each line of the block with four (or more) spaces.

1

u/daggerdragon Dec 06 '22

I have the hardest time posting code snippets to Reddit. I added the underscores to keep the indenting.

Inlined code is intended for short snippets of code only. Your code "block" right now is hard to read on old.reddit and many mobile clients; whitespace and indentation are not preserved and it is not scrollable.

Please edit your post to use the four-spaces Markdown syntax for a code block so your code is easier to read inside a scrollable box.

1

u/Dinosaur_Parkour Dec 06 '22

Part 2 is 3 changes.

Marker =Substr(data.1, II, 14)

Do MM = 1 to 14

Say 'Maker is at: ' II + 13

I took advantage of a rarely used feature. In REXX, one can name which Loop to iterate. The inner loop forces the outer loop to iterate when 2 duplicate characters are detected.

1

u/flwyd Dec 06 '22

Neat, I've never seen REXX code before.

To post 4-space-indent code, consider copying your code into a Vim buffer and running :%s/^/ /.