feat: fuck me...only count occurrences of landing on and then beginning on zero once
This commit is contained in:
+20
-34
@@ -2,8 +2,6 @@
|
|||||||
package dial
|
package dial
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/StevanFreeborn/advent-of-code-2025/cmd/01/direction"
|
"github.com/StevanFreeborn/advent-of-code-2025/cmd/01/direction"
|
||||||
"github.com/StevanFreeborn/advent-of-code-2025/cmd/01/instruction"
|
"github.com/StevanFreeborn/advent-of-code-2025/cmd/01/instruction"
|
||||||
)
|
)
|
||||||
@@ -42,55 +40,43 @@ func (d *dial) Value() int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *dial) Turn(instruction instruction.Instruction) {
|
func (d *dial) Turn(instruction instruction.Instruction) {
|
||||||
logPrefix := fmt.Sprintf("[TURN %s %d]", instruction.Direction(), instruction.Distance())
|
|
||||||
|
|
||||||
if d.value < 0 || d.value > 99 {
|
|
||||||
panic("NEVER SHALL YOU PASS!!!")
|
|
||||||
}
|
|
||||||
|
|
||||||
// d.value is always 0 to 99
|
|
||||||
|
|
||||||
if instruction.Direction() == direction.Left {
|
if instruction.Direction() == direction.Left {
|
||||||
if d.value == 0 {
|
for range instruction.Distance() {
|
||||||
d.zeroCount--
|
d.decreaseOneClick()
|
||||||
}
|
|
||||||
|
|
||||||
d.value -= instruction.Distance()
|
|
||||||
|
|
||||||
// that here we are at 0
|
|
||||||
|
|
||||||
if d.value == 0 {
|
if d.value == 0 {
|
||||||
fmt.Printf("%s zeroCount++\n", logPrefix)
|
|
||||||
d.zeroCount++
|
d.zeroCount++
|
||||||
}
|
}
|
||||||
|
|
||||||
for d.value < 0 {
|
if d.value < 0 {
|
||||||
// WE NEVER GET HERE
|
|
||||||
// UNLESS d.value is -1 or less
|
|
||||||
currentValue := d.value
|
|
||||||
d.zeroCount++
|
|
||||||
d.value += 100
|
d.value += 100
|
||||||
fmt.Printf("%s zeroCount++ => Correcting %d to %d (%d)\n", logPrefix, currentValue, d.value, d.zeroCount)
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if instruction.Direction() == direction.Right {
|
if instruction.Direction() == direction.Right {
|
||||||
d.value += instruction.Distance()
|
for range instruction.Distance() {
|
||||||
|
d.increaseOneClick()
|
||||||
|
|
||||||
// that here we at 100 or the equilavent
|
if d.value >= 100 {
|
||||||
// of 0. this is counted
|
|
||||||
|
|
||||||
for d.value > 99 {
|
|
||||||
// WE NEVER GET HERE
|
|
||||||
// UNLESS d.value is 100 or more
|
|
||||||
currentValue := d.value
|
|
||||||
d.zeroCount++
|
|
||||||
d.value -= 100
|
d.value -= 100
|
||||||
fmt.Printf("%s zeroCount++ => Correcting %d to %d (%d)\n", logPrefix, currentValue, d.value, d.zeroCount)
|
}
|
||||||
|
|
||||||
|
if d.value == 0 {
|
||||||
|
d.zeroCount++
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *dial) decreaseOneClick() {
|
||||||
|
d.value--
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *dial) increaseOneClick() {
|
||||||
|
d.value++
|
||||||
|
}
|
||||||
|
|||||||
+1
-1
@@ -38,7 +38,7 @@ func TestSolvePartTwoWithExampleInput(t *testing.T) {
|
|||||||
|
|
||||||
func TestSolvePartTwoWithInput(t *testing.T) {
|
func TestSolvePartTwoWithInput(t *testing.T) {
|
||||||
expected := -1
|
expected := -1
|
||||||
tooLow := 5849
|
tooLow := 5922
|
||||||
tooHigh := 5967
|
tooHigh := 5967
|
||||||
|
|
||||||
result := solution.SolvePartTwo("INPUT.txt")
|
result := solution.SolvePartTwo("INPUT.txt")
|
||||||
|
|||||||
Reference in New Issue
Block a user