AoC/2019/AoC.playground/Pages/Day 4.xcplaygroundpage/Contents.swift
2022-11-23 16:46:51 +01:00

23 lines
410 B
Swift

let min = 172930
let max = 683082
var count = 0
outer: for i in min...max {
let s = String(i).compactMap { $0.wholeNumberValue }
var hasDouble = false
for (first, second) in zip(s, s.dropFirst()) {
if second < first {
continue outer
}
if first == second {
hasDouble = true
}
}
guard hasDouble else { continue }
count += 1
}