EXAPUNKS
评价数不足
DAY 1 PART 2 ADVENT OF CODE 2018 - CHRONAL CALIBRATION
   
奖励
收藏
已收藏
取消收藏
文件大小
发表于
1.670 KB
2018 年 12 月 1 日 上午 5:02
1 项改动说明 ( 查看 )

订阅以下载
DAY 1 PART 2 ADVENT OF CODE 2018 - CHRONAL CALIBRATION

在 Mus_niro 的 1 个合集中
EXAPUNKS - Advent of Code 2018
3 件物品
描述
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://psteamcommunity.yuanyoumao.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 条留言
Mus_niro  [作者] 2018 年 12 月 1 日 上午 11:48 
@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 2018 年 12 月 1 日 上午 11:10 
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. :)