Advertisement
31ph4n70m

Neumann's_Random_Generator.kt

Dec 19th, 2019
1,002
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.73 KB | None | 0 0
  1. // kotlin solution to codeabbey challenge 24
  2. fun main(args: Array<String>) {
  3.     var inp2: IntArray = intArrayOf(3488, 373, 5368, 751, 8342, 3416, 843, 6173, 7019, 381, 1054, 6303);
  4.     var counter = 0;
  5.     var rsp = mutableListOf<String>();
  6.     var vals = mutableListOf<Int>();
  7.     var aux = 0;
  8.     var aux2 = 0;
  9.     for (i in inp2) {
  10.         aux = i;
  11.         label@ while (true) {
  12.             aux2 = (aux * aux / 100) % 10000;
  13.             if (vals.contains(aux)) {
  14.                 rsp.add(counter.toString());
  15.                 break@label;
  16.             }
  17.             vals.add(aux);
  18.             counter += 1;
  19.             aux = aux2;
  20.         }
  21.         counter = 0;
  22.         vals.clear();
  23.     }
  24.     println(rsp.joinToString(" "));
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement