import Foundation
let s = "Swift programming language is a general-purpose programming language"
// Split the string into words
let words = s.lowercased().components(
separatedBy: CharacterSet.punctuationCharacters.union(.whitespacesAndNewlines))
// Remove empty strings
let filteredWords = words.filter { !$0.isEmpty }
// Use a Set to store unique words
let uniqueWords = Set(filteredWords)
let uniqueWordCount = uniqueWords.count
print("Unique words: \(uniqueWords)")
print("Number of unique words: \(uniqueWordCount)")
/*
run:
Unique words: ["purpose", "is", "swift", "programming", "a", "general", "language"]
Number of unique words: 7
*/