Robert Mion

Posted on

# Timing is Everything

## Part 1

1. A LCM puzzle?
2. What better way than to just try counting up?

### A LCM puzzle?

LCM: Least Common Multiple

• The smallest number shared by several numbers as that which they evenly divide by

`3,5 = 15`
`2,5 = 10`

In this case, the numbers may be some combination of the time passed, the total positions, and the current position of each disc.

### What better way than to just try counting up?

``````Create a variable, answer
Create a counter, starting at 0
Do as long as answer has no value
Determine whether each disc would be at position 0 when reached
If so
Else
Increment counter
``````

What is the equation I'll use to determine whether a disc is at position 0?

``````(time + disc number + position) % positions == 0
``````

For example:

So, as long as each disc's equation becomes 0 for a time, then I found a winning time!

This algorithm seems easy enough to write.

Here I go!

...

It worked!

## Part 2

### Easiest Part 2 ever?

• If I am reading this correctly, I just need to alter my puzzle input so it includes an extra disc
• Then run my algorithm again...hoping that this extra disc doesn't cause the first time to press the button to become a number in the billions or trillions

After adding this line to my puzzle input:

``````Disc #7 has 11 positions; at time=0, it is at position 0.
``````

And running my algorithm again...

It almost immediately generated a number.