dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
1.5 KiB
1.5 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 69b58ce40693f140c84c855b | Challenge 242: Next Bingo Number | 28 | challenge-242 |
--description--
Given a bingo number, return the next bingo number sequentially.
A bingo number is a single letter followed by a number in its range according to this chart:
| Letter | Number Range |
|---|---|
"B" |
1-15 |
"I" |
16-30 |
"N" |
31-45 |
"G" |
46-60 |
"O" |
61-75 |
For example, given "B10", return "B11", the next bingo number. If given the last bingo number, return "B1".
--hints--
getNextBingoNumber("B10") should return "B11".
assert.equal(getNextBingoNumber("B10"), "B11");
getNextBingoNumber("N33") should return "N34".
assert.equal(getNextBingoNumber("N33"), "N34");
getNextBingoNumber("I30") should return "N31".
assert.equal(getNextBingoNumber("I30"), "N31");
getNextBingoNumber("G60") should return "O61".
assert.equal(getNextBingoNumber("G60"), "O61");
getNextBingoNumber("O75") should return "B1".
assert.equal(getNextBingoNumber("O75"), "B1");
--seed--
--seed-contents--
function getNextBingoNumber(n) {
return n;
}
--solutions--
function getNextBingoNumber(n) {
const num = parseInt(n.slice(1));
const next = num === 75 ? 1 : num + 1;
if (next <= 15) return "B" + next;
if (next <= 30) return "I" + next;
if (next <= 45) return "N" + next;
if (next <= 60) return "G" + next;
return "O" + next;
}