Today   (2020-02-02,   at the time of this writing)   happens to be a palindrome,   without the hyphens,   not only for those countries which express their dates in the   yyyy-mm-dd   format but,   unusually,   also for countries which use the   dd-mm-yyyy   format.



Task
Write a program which calculates and shows the next 15 palindromic dates for those countries which express their dates in the   yyyy-mm-dd   format.




import Foundation
 
func isPalindrome(_ string: String) -> Bool {
    let chars = string.lazy
    return chars.elementsEqual(chars.reversed())
}
 
let format = DateFormatter()
format.dateFormat = "yyyyMMdd"
 
let outputFormat = DateFormatter()
outputFormat.dateFormat = "yyyy-MM-dd"
 
var count = 0
let limit = 15
let calendar = Calendar.current
var date = Date()
 
while count < limit {
    if isPalindrome(format.string(from: date)) {
        print(outputFormat.string(from: date))
        count += 1
    }
    date = calendar.date(byAdding: .day, value: 1, to: date)!
}