···126126let amp = amp % 100;
127127```
128128129129-And easy way to detect a crossing is to check if the difference in `curr` and `prev` is opposite to what we expected. For example, let's say dial position is at `5` and we get input `L10`, as the `dir` is `L`, the dial position should decrease, that is, `curr` < `prev`, but as the `amp` was 10, the new dial position becomes `95`. Now, `curr` (95) > `prev` (5). Detecting for this, and similarly `curr` < `prev` for `R`, we can get if there was a crossing on this move! One thing we need to keep in mind is to ignore those where either `curr` or `prev` were 0, as they would have been already counted by `tot`!
129129+An easy way to detect a crossing is to check if the difference in `curr` and `prev` is opposite to what we expected.
130130+131131+For example, let's say dial position is at `5` and we get input `L10`, as the `dir` is `L`, the dial position should decrease, that is, `curr` < `prev`, but as the `amp` was 10, the new dial position becomes `95`. Now, `curr` (95) > `prev` (5).
132132+133133+Detecting for this, and similarly `curr` < `prev` for `R`, we can check if there was a crossing on this move!
134134+135135+One thing we need to keep in mind is to ignore those where either `curr` or `prev` were 0, as they would have been already counted by `tot`!
130136131137:::duck
132138Also, do remember to set `prev = curr` at the end, you don't want to know how much time I spent debugging this!
+7-1
src/content/aoc/2025/01.org
···9191 let amp = amp % 100;
9292#+end_src
93939494-And easy way to detect a crossing is to check if the difference in =curr= and =prev= is opposite to what we expected. For example, let's say dial position is at =5= and we get input =L10=, as the =dir= is =L=, the dial position should decrease, that is, =curr= < =prev=, but as the =amp= was 10, the new dial position becomes =95=. Now, =curr= (95) > =prev= (5). Detecting for this, and similarly =curr= < =prev= for =R=, we can get if there was a crossing on this move! One thing we need to keep in mind is to ignore those where either =curr= or =prev= were 0, as they would have been already counted by =tot=!
9494+An easy way to detect a crossing is to check if the difference in =curr= and =prev= is opposite to what we expected.
9595+9696+For example, let's say dial position is at =5= and we get input =L10=, as the =dir= is =L=, the dial position should decrease, that is, =curr= < =prev=, but as the =amp= was 10, the new dial position becomes =95=. Now, =curr= (95) > =prev= (5).
9797+9898+Detecting for this, and similarly =curr= < =prev= for =R=, we can check if there was a crossing on this move!
9999+100100+One thing we need to keep in mind is to ignore those where either =curr= or =prev= were 0, as they would have been already counted by =tot=!
9510196102:::duck
97103Also, do remember to set =prev = curr= at the end, you don't want to know how much time I spent debugging this!