Skip to content

Commit

Permalink
Solución Reto mouredev#1 PHP
Browse files Browse the repository at this point in the history
  • Loading branch information
lombervid committed Jan 2, 2023
1 parent 2b62876 commit 2db2283
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions Retos/Reto #1 - EL LENGUAJE HACKER [Fácil]/php/lombervid.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php
declare(strict_types=1);

function hackerLanguage(string $input): string
{
$alphabet = [
"a" => "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 str_replace(array_keys($alphabet), array_values($alphabet), strtolower($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);
}

0 comments on commit 2db2283

Please sign in to comment.