Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. let input =[11, 44, 69, 46, 63, 83, 13, 62, 14, 31, 68, 87];
  2. let gets = this.gets || ((input, index) => () => input[index++]) (input, 0);
  3. let print = this.print || console.log;
  4.  
  5. let n = +input.shift();
  6. let str = input.toString().replace(/,/g, ' ').split(' ');
  7. let mergedNum = '';
  8. let squashedNum; // any type
  9. let mergedArr = [];
  10. let squashedArr = [];
  11.  
  12. for (let i = 0; i < input.length - 1; i++) {
  13. mergedNum = str[i].charAt(1) + str[i + 1].charAt(0);
  14.  
  15. mergedArr.push(mergedNum).toString().split('').map(Number);
  16. }
  17. print(mergedArr.join(' '));
  18.  
  19. for (let i = 0; i < input.length - 1; i++) {
  20.  
  21. let sum = 0;
  22.  
  23. let sumPart1 = parseInt(str[i].charAt(1));
  24. let sumPart2 = parseInt(str[i + 1].charAt(0));
  25. sum += (sumPart1 + sumPart2) % 10;
  26. squashedNum = str[i].charAt(0) + sum + str[i + 1].charAt(1);
  27.  
  28. squashedArr.push(squashedNum).toString().split('').map(Number);
  29. }
  30. print(squashedArr.join(' '));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement