Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function weddingSeats(input) {
- let finalSector = input[0].charCodeAt(0);
- let rows = Number(input[1]);
- let oddSeats = Number(input[2]);
- let totalSeats = 0;
- for (let i = 'A'.charCodeAt(0); i <= finalSector; i++) {
- for (let k = 1; k <= rows; k++) {
- let currentSeats = oddSeats;
- if (k % 2 === 0) {
- currentSeats += 2;
- }
- for (let o = 'a'.charCodeAt(0); o < currentSeats + 97; o++) {
- console.log(`${String.fromCharCode(i)}${k}${String.fromCharCode(o)}`);
- totalSeats++;
- }
- }
- rows++;
- }
- console.log(totalSeats);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement