Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // PHP solution to codeabbey challenge 72
- $INP1 = array_map('intval', explode(' ', "22 1838911"));
- $INP2 = "3 5 5 4 6 8 8 5 3 5 4 7 6 4 3 5 5 7 7 5 8 6";
- $INP2 = array_map('intval', explode(" ", $INP2));
- $CON = str_split('bcdfghjklmnprstvwxz');
- $VOW = str_split('aeiou');
- $A = 445;
- $C = 700001;
- $M = 2097152;
- $XN = $INP1[1];
- $LI = 0;
- $RSP = [];
- foreach ($INP2 as $wl) {
- $WORD = "";
- for ($i = 1; $i <= $wl; $i++) {
- $XN = ($A*$XN + $C) % $M;
- if ($i % 2 == 0) {
- $LI = $XN % 5;
- $WORD .= $VOW[$LI];
- } else {
- $LI = $XN % 19;
- $WORD .= $CON[$LI];
- }
- }
- array_push($RSP, $WORD);
- }
- echo implode(" ", $RSP);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement