From 5e2c2bee513f759e67758cd5e2fac36bb252f305 Mon Sep 17 00:00:00 2001 From: David Lombera Date: Mon, 2 Jan 2023 15:36:12 -0600 Subject: [PATCH] =?UTF-8?q?Soluci=C3=B3n=20Reto=20#1=20PHP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../php/lombervid.php" | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 "Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/php/lombervid.php" diff --git "a/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/php/lombervid.php" "b/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/php/lombervid.php" new file mode 100644 index 0000000000..26096a159d --- /dev/null +++ "b/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/php/lombervid.php" @@ -0,0 +1,56 @@ + "4", + "b" => "I3", + "c" => "[", + "d" => ")", + "e" => "3", + "f" => "|=", + "g" => "&", + "h" => "#", + "i" => "1", + "j" => ",_|", + "k" => ">|", + "l" => "1", + "m" => "/\\/\\", + "n" => "^/", + "o" => "0", + "p" => "|*", + "q" => "(_,)", + "r" => "I2", + "s" => "5", + "t" => "7", + "u" => "(_)", + "v" => "\\/", + "w" => "\\/\\/", + "x" => "><", + "y" => "j", + "z" => "2", + ]; + + return strtr(strtolower($input), $alphabet); + // return str_ireplace(array_keys($alphabet), $alphabet, $input); +} + +// Main code +$cases = [ + "demo" => ")3/\\/\\0", + "hacker" => "#4[>|3I2", + "Hello World!" => "#3110 \\/\\/0I21)!", +]; + +foreach ($cases as $input => $want) { + $got = hackerLanguage($input); + + if ($want === $got) { + print("Case passed:"); + } else { + print("Case failed"); + } + + printf("\n\tinput:\t\"%s\"\n\twant:\t\"%s\"\n\tgot:\t\"%s\"\n\n", $input, $want, $got); +}