2024 day 2 part 2 - remove unused code

This commit is contained in:
Mans Ziesel 2024-12-02 16:05:10 +01:00
parent c26376f49d
commit 2345680352

View File

@ -6,7 +6,6 @@ import (
"log"
"math"
"os"
// "slices"
"strconv"
"strings"
)
@ -68,7 +67,6 @@ func checkSafe(nums []int) bool {
var current int
var isIncreasing bool
isSafe := true
firstFailedIdx := -1
for idx, num := range nums {
current = num
@ -77,9 +75,6 @@ func checkSafe(nums []int) bool {
continue
}
if prev == current {
if firstFailedIdx == -1 {
firstFailedIdx = idx
}
isSafe = false
break
}
@ -89,21 +84,12 @@ func checkSafe(nums []int) bool {
diff := int(math.Abs(float64(prev) - float64(current)))
if diff < 1 || diff > 3 {
if firstFailedIdx == -1 {
firstFailedIdx = idx
}
isSafe = false
}
if isIncreasing && (prev > current) {
if firstFailedIdx == -1 {
firstFailedIdx = idx
}
isSafe = false
}
if !isIncreasing && (prev < current) {
if firstFailedIdx == -1 {
firstFailedIdx = idx
}
isSafe = false
}