Advertisement
31ph4n70m

Neumann's_Random_Generator.pl

Dec 19th, 2019
1,124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.56 KB | None | 0 0
  1. # Perl solution to codeabbey challenge 24
  2. use experimental 'smartmatch';
  3.  
  4. $inp1 = 12;
  5. @inp2 = (3488, 373, 5368, 751, 8342, 3416, 843, 6173, 7019, 381, 1054, 6303);
  6. $counter = 0;
  7. $rsp = ();
  8. $vals = ();
  9. $aux = 0;
  10. $aux2 = 0;
  11. foreach $a (@inp2) {
  12.     $aux = $a;
  13.     for( ; ; ) {
  14.         $aux2 = ($aux * $aux / 100) % 10000;
  15.         if ($aux ~~ @vals) {
  16.             push(@rsp, $counter);
  17.             last;
  18.         }
  19.         push(@vals, $aux);
  20.         $counter += 1;
  21.         $aux = $aux2;
  22.    }
  23.    $counter = 0;
  24.    @vals = ();
  25. }
  26. print join( ' ', @rsp );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement