Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Perl solution to codeabbey challenge 24
- use experimental 'smartmatch';
- $inp1 = 12;
- @inp2 = (3488, 373, 5368, 751, 8342, 3416, 843, 6173, 7019, 381, 1054, 6303);
- $counter = 0;
- $rsp = ();
- $vals = ();
- $aux = 0;
- $aux2 = 0;
- foreach $a (@inp2) {
- $aux = $a;
- for( ; ; ) {
- $aux2 = ($aux * $aux / 100) % 10000;
- if ($aux ~~ @vals) {
- push(@rsp, $counter);
- last;
- }
- push(@vals, $aux);
- $counter += 1;
- $aux = $aux2;
- }
- $counter = 0;
- @vals = ();
- }
- print join( ' ', @rsp );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement