EXAPUNKS

EXAPUNKS

Not enough ratings
DAY 1 PART 2 ADVENT OF CODE 2018 - CHRONAL CALIBRATION
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
1.670 KB
Dec 1, 2018 @ 5:02am
1 Change Note ( view )

Subscribe to download
DAY 1 PART 2 ADVENT OF CODE 2018 - CHRONAL CALIBRATION

In 1 collection by Mus_niro
EXAPUNKS - Advent of Code 2018
3 items
Description
This is the EXAPUNKS version of https://adventofcode.com/2018/day/1

What is Advent of Code: https://adventofcode.com/2018/about

The puzzle input has been changed to accomodate for the smaller registers

part 1 of this day can be found at https://steamcommunity.com/sharedfiles/filedetails/?id=1579334885

This is the original puzzle description:

--- Part Two ---

You notice that the device repeats the same frequency change list over and over. To calibrate the device, you need to find the first frequency it reaches twice.

For example, using the same list of changes above, the device would loop as follows:

Current frequency 0, change of +1; resulting frequency 1.
Current frequency 1, change of -2; resulting frequency -1.
Current frequency -1, change of +3; resulting frequency 2.
Current frequency 2, change of +1; resulting frequency 3.
(At this point, the device continues from the start of the list.)
Current frequency 3, change of +1; resulting frequency 4.
Current frequency 4, change of -2; resulting frequency 2, which has already been seen.

In this example, the first frequency reached twice is 2. Note that your device might need to repeat its list of frequency changes many times before a duplicate frequency is found, and that duplicates might be found while in the middle of processing the list.

Here are other examples:

+1, -1 first reaches 0 twice.
+3, +3, +4, -2, -4 first reaches 10 twice.
-6, +3, +8, +5, -6 first reaches 5 twice.
+7, +7, -2, -7, -4 first reaches 14 twice.

What is the first frequency your device reaches twice?
2 Comments
Mus_niro  [author] Dec 1, 2018 @ 11:48am 
@zwippie, I'm happy you like it! Yes the first one is correct: you start at frequency 0 and after the first 4 values the frequency is 0 again (+76 + -43 + 17 + -50 = 0). This is the same case as one of the examples in the puzzle description '+1, -1 first reaches 0 twice'. Funny that it appeared in the first test.

Yeah, I'll try to port as many as I can. Doing anything with strings will be next to impossible though.
zwippie Dec 1, 2018 @ 11:10am 
I have created a solution that succeeds for all test runs excecpt the first one! Are you sure the answer for the first one is correct? It says it should be 0 but I doubt that.

Thanks for converting the AOC puzzles, looking forward to the next days. Very curious if they keep being simple enough to translate to Exapunks. :)