PavelIvanov

Untitled

May 23rd, 2020
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. function solve(input) {
  2. let a = Number(input.shift());
  3. let b = Number(input.shift());
  4. let maxCountPass = Number(input.shift());
  5. let output = '';
  6. let counter = 0;
  7. let firstLetter = 35;
  8. let secondLetter = 64;
  9.  
  10. for (let j = 1; j <= a; j++) {
  11. for (let k = 1; k <= b; k++) {
  12. if (counter >= maxCountPass) {
  13. break;
  14. }
  15. let strJ = String.fromCharCode(firstLetter);
  16. let strK = String.fromCharCode(secondLetter);
  17. output += `${strJ}${strK}${j}${k}${strK}${strJ}|`;
  18.  
  19. firstLetter++;
  20. secondLetter++;
  21. counter++;
  22. if (firstLetter >= 55) {
  23. firstLetter = 35;
  24. }
  25. if (secondLetter >= 96) {
  26. secondLetter = 64;
  27. }
  28. }
  29. }
  30. console.log(output);
  31. }
  32. solve( ['20', '50', '10'])
Add Comment
Please, Sign In to add comment