Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $key = array_map("intval", explode(" ", readline()));
- $input = readline();
- $finalResult = "";
- $finalResults = [];
- while ($input !== "find") {
- $input = str_split($input);
- for ($j = 0; $j < count($input); $j++){
- for ($i = 0; $i < count($key); $i++){
- if ($i === count($key)) {
- break;
- }
- $input[$i] = chr(ord($input[$i]) - $key[$i]);
- }
- $finalResult .= substr(implode("", $input), 0, count($key));
- array_splice($input,0, count($key));
- }
- if (count($input) !== 0) {
- for ($n = 0; $n < count($input);$n++){
- if ($n >= count($key)) {
- $n = 0;
- array_splice($input, 0, count($key));
- }
- $finalResult .= chr(ord($input[$n]) - $key[$n]);
- }
- }
- $finalResults[] = $finalResult;
- $finalResult = "";
- $input = readline();
- }
- foreach ($finalResults as $result) {
- list($randomWord, $treasureName, $coordinates) = explode("&", $result);
- if (preg_match("/(?<=\<)\w+(?=\>)/", $coordinates, $matches)) {
- $matched = $matches[0];
- }
- echo "Found $treasureName at " . $matched . PHP_EOL;
- }
Advertisement
Add Comment
Please, Sign In to add comment