Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Typescript solution to codeabbey challenge 24
- declare interface Math {
- trunc(x: number): number;
- }
- function main() {
- const inp2 = [3488, 373, 5368, 751, 8342, 3416, 843, 6173, 7019, 381, 1054, 6303];
- let counter = 0;
- const rsp: number[] = [];
- let vals: number[] = [];
- let aux = 0;
- let aux2 = 0;
- for (const i of inp2) {
- aux = i;
- while (true) {
- aux2 = Math.trunc((aux * aux / 100) % 10000);
- if (vals.some((elm) => elm === aux)) {
- rsp.push(counter);
- break;
- }
- vals.push(aux);
- counter += 1;
- aux = aux2;
- }
- counter = 0;
- vals = [];
- }
- console.log(rsp.join(" "));
- }
- main();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement