I just cant find my issue what i've done wrong with that brute-force approach. It does work for the example input but it does not work for that main input, i just get a wrong result.
func part2() int {
digits := getDigits()
var smallestSeed = 999999999999
var seedRanges = strings.Split(data[0], " ")
for index := 1; index < len(seedRanges); index += 2 {
value, err := strconv.Atoi(seedRanges[index])
value2, err2 := strconv.Atoi(seedRanges[index+1])
if err != nil && err2 != nil {
continue
}
for rangeIndex := 0; rangeIndex < value2; rangeIndex++ {
var seed = value + rangeIndex
for section := 0; section < len(digits); section++ {
for index := 0; index < len(digits[section]); index += 3 {
var source = digits[section][index+1]
var destination = digits[section][index]
var length = digits[section][index+2]
if source <= seed && source+length >= seed {
var difference = seed - source
seed = destination + difference
break
}
}
}
if seed < smallestSeed {
smallestSeed = seed
}
}
}
return smallestSeed
}




