Advertisement
Spocoman

06. Wedding Seats

Jan 1st, 2022
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function weddingSeats(input) {
  2.     let finalSector = input[0].charCodeAt(0);
  3.     let rows = Number(input[1]);
  4.     let oddSeats = Number(input[2]);
  5.     let totalSeats = 0;
  6.  
  7.     for (let i = 'A'.charCodeAt(0); i <= finalSector; i++) {
  8.         for (let k = 1; k <= rows; k++) {
  9.             let currentSeats = oddSeats;
  10.             if (k % 2 === 0) {
  11.                 currentSeats += 2;
  12.             }
  13.             for (let o = 'a'.charCodeAt(0); o < currentSeats + 97; o++) {
  14.                 console.log(`${String.fromCharCode(i)}${k}${String.fromCharCode(o)}`);
  15.                 totalSeats++;
  16.             }
  17.         }
  18.         rows++;
  19.     }
  20.     console.log(totalSeats);
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement