Advertisement
Spocoman

Ticket Combination

Sep 29th, 2023
834
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function ticketCombination(input) {
  2.     let n = Number(input);
  3.  
  4.     for (let a = 'B'.charCodeAt(0); a <= 'L'.charCodeAt(0); a += 2) {
  5.         for (let b = 'f'.charCodeAt(0); b >= 'a'.charCodeAt(0); b--) {
  6.             for (let c = 'A'.charCodeAt(0); c <= 'C'.charCodeAt(0); c++) {
  7.                 for (let d = 1; d <= 10; d++) {
  8.                     for (let e = 10; e > 0; e--) {
  9.                         if (--n == 0) {
  10.                             console.log(`Ticket combination: ${String.fromCharCode(a, b, c)}${d}${e}`);
  11.                             console.log(`Prize: ${a + b + c + d + e} lv.`);
  12.                             return;
  13.                         }
  14.                     }
  15.                 }
  16.             }
  17.         }
  18.     }
  19.     return;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement