Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func confuser() {
- if let fileURL = Bundle.main.url(forResource: "screams", withExtension: nil) {
- do {
- let contents = try String(contentsOf: fileURL, encoding: String.Encoding.utf8)
- let words = contents.components(separatedBy: "\n")
- for word in words {
- let line = word.components(separatedBy: .punctuationCharacters)
- .joined().components(separatedBy: .whitespaces)
- .joined().lowercased()
- let enil = String(line.reversed())
- if (word == "") { continue; }
- if line == enil {
- print("AY|" + word);
- } else {
- print("NAY|" + enil);
- }
- }
- } catch { print("Error: \(error.localizedDescription)") }
- } else { print("No such file URL.") }
- }
Advertisement
Add Comment
Please, Sign In to add comment