@@ 0,0 1,38 @@
+package main
+
+import "fmt"
+
+func calcCombinations(lower int, higher int) (int, int) {
+ combinations := 0
+ isolatedCombinations := 0
+ for i := lower; i <= higher; i++ {
+ arr := []byte(fmt.Sprintf("%06d", i))
+ twoMatching := false
+ isIncreasing := true
+ twoIsolatedMatching := false
+ for j := 0; j < len(arr)-1; j++ {
+ if arr[j] == arr[j+1] {
+ twoMatching = true
+ if (j < 1 || arr[j-1] != arr[j]) && (j >= len(arr)-2 || arr[j+2] != arr[j]) {
+ twoIsolatedMatching = true
+ }
+ }
+ if arr[j] > arr[j+1] {
+ isIncreasing = false
+ }
+ }
+ if twoMatching == true && isIncreasing == true {
+ combinations++
+ }
+ if twoIsolatedMatching == true && isIncreasing == true {
+ isolatedCombinations++
+ }
+ }
+ return combinations, isolatedCombinations
+}
+
+func main() {
+ lower := 130254
+ higher := 678275
+ fmt.Println(calcCombinations(lower, higher))
+}