Advertisement
31ph4n70m

Neumann's_Random_Generator.ts

Dec 19th, 2019
592
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Typescript solution to codeabbey challenge 24
  2. declare interface Math {
  3.     trunc(x: number): number;
  4. }
  5.  
  6. function main() {
  7.   const inp2 = [3488, 373, 5368, 751, 8342, 3416, 843, 6173, 7019, 381, 1054, 6303];
  8.   let counter = 0;
  9.   const rsp: number[] = [];
  10.   let vals: number[] = [];
  11.   let aux = 0;
  12.   let aux2 = 0;
  13.   for (const i of inp2) {
  14.     aux = i;
  15.     while (true) {
  16.       aux2 = Math.trunc((aux * aux / 100) % 10000);
  17.       if (vals.some((elm) => elm === aux)) {
  18.         rsp.push(counter);
  19.         break;
  20.       }
  21.       vals.push(aux);
  22.       counter += 1;
  23.       aux = aux2;
  24.     }
  25.     counter = 0;
  26.     vals = [];
  27.   }
  28.   console.log(rsp.join(" "));
  29. }
  30.  
  31. main();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement