From 0359d60af8b2e6d37ece310fd5a46b3293c02c75 Mon Sep 17 00:00:00 2001 From: allbertoMD Date: Fri, 26 Apr 2024 12:58:52 +0200 Subject: [PATCH] #01-Swift --- .../swift/allbertoMD.swift" | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 "Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/swift/allbertoMD.swift" diff --git "a/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/swift/allbertoMD.swift" "b/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/swift/allbertoMD.swift" new file mode 100644 index 0000000000..1f7097e08d --- /dev/null +++ "b/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/swift/allbertoMD.swift" @@ -0,0 +1,30 @@ +import Foundation + + +let hackerDictionary: [Character : String] = [ + "a" : "4", "b" : "I3", "c" : "[", "d" : ")", "e" : "3", "f" : "|=", "g" : "&", "h" : "#", + "i" : "1", "j" : ",_|", "k" : ">|", "l" : "|_", "m" : "/\\/\\", "n" : "^/", "o" : "0", + "p" : "|*", "q" : "(_,)", "r" : "I2", "s" : "5", "t" : "7", "u" : "(_)", "v" : "\\/", "w" : "\\/\\/", + "x" : "><", "y" : "`/", "z" : "-/_", " " : " ", "A" : "4", "B" : "I3", "C" : "[", "D" : ")", + "E" : "3", "F" : "|=", "G" : "&", "H" : "#", "I" : "1", "J" : ",_|", "K" : ">|", "L" : "|_", + "M" : "/\\/\\", "N" : "^/", "O" : "0","P" : "|*", "Q" : "(_,)", "R" : "I2", "S" : "5", + "T" : "7", "U" : "(_)", "V" : "\\/", "W" : "\\/\\/", "X" : "><", "Y" : "`/", "Z" : "-/_" +] + +func printHackerLenguage(_ str: String) -> String { + var hackerWord = "" + + for s in str { + if let value = hackerDictionary[s] { + hackerWord.append(value) + } + } + return hackerWord +} + +print("Ingresa el texto:") +if let input = readLine() { + let hackerWord = printHackerLenguage(input) + print(hackerWord) +} +