Skip to main content
Commonmark migration
Source Link

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?

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?

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?

Tweeted twitter.com/StackCodeReview/status/1069154324511625216
edited body; edited tags; edited title
Source Link
200_success
  • 144.2k
  • 22
  • 188
  • 473

slow advent Advent of codeCode 2018 day 1 part 2 solution in haskell: find the first repeated number after some increases and decreases

Part Two

--- 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.

THisThis is seriously slow.

slow advent of code 2018 day 1 part 2 solution in haskell

--- 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.

THis is seriously slow.

Advent of Code 2018 day 1 part 2: find the first repeated number after some increases and decreases

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.

This is seriously slow.

added 19 characters in body
Source Link
vnp
  • 57.3k
  • 4
  • 51
  • 140

--- 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 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 from the start of the list.) 

Current frequency 3, change of +1; resulting resulting frequency 4. 

Current frequency 4, change of -2; resulting frequency frequency 2, which has already been seen. 

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

Here are other examples:

+1, -1 first reaches 0 twice. +3

+3, +3, +4, -2, -4 first reaches 10 twice.   

-6, +3, +8, +5, -6 first reaches 5 twice. +7

+7, +7, -2, -7, -4 first reaches 14 twice. 

What is the first frequency your device reaches twice?

--- 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?

--- 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?

Source Link
dagda1
  • 309
  • 2
  • 8
Loading