func hasUniqueDigits(number: String) -> Bool {
var numbers = [1, 2, 3, 4, 5, 6, 7]
for i in 1...6 {
var partOne = number.firstIndex(of: String.Element("\(i)"))
var partTwo = String(numbers.firstIndex(of: Int(partOne))!)
numbers.remove(at: partTwo)
}
if numbers.count == 1 {
return true
} else {
return false
This is a function for determining whether a six-digit number containing only the digits 1-7 contains all unique digits. Examples: 145327 works, 114723 doesn't because it has two ones, and 183427 doesn't because it contains an 8. I have typed in random !'s to see if it was an optional problem and that didn't work. Can you please let me know hot to fix this error?