This commit is contained in:
Sven Weidauer 2022-11-23 16:45:30 +01:00
parent c7deb3c71d
commit ddf5ec2274
56 changed files with 6756 additions and 1 deletions

View file

@ -0,0 +1,23 @@
func step(_ input: String) -> String {
var position = input.startIndex
var output = ""
while position < input.endIndex {
let next = input[position...].firstIndex(where: { $0 != input[position] }) ?? input.endIndex
let distance = input.distance(from: position, to: next)
output += "\(distance)\(input[position])"
position = next
}
return output
}
var current = "1321131112"
for _ in 0..<50 {
current = step(current)
}
current
current.count