Last active
July 24, 2023 04:01
-
-
Save Grubba27/2d65c09bcf2a138928e08ee8b46c817a to your computer and use it in GitHub Desktop.
find possiblities
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// given a string, list the possible cenarios for each character, given that if the word has a | |
// ? it should be either "E" or "U" | |
// example: "???" -> ["EEE", "EEU", "EUE", "EUU", "UEE", "UEU", "UUE", "UUU"] | |
// example: "??U" -> ["EEU", "EUU", "UEU", "UUU"] | |
// example "fo?" -> ["foE", "foU"] | |
/** | |
* | |
* @param {string} str | |
* @returns {string[]} | |
*/ | |
function questionMark(str) { | |
// implement | |
} | |
/** | |
* | |
* @param {string} name | |
* @param { } callback | |
*/ | |
function assement(name, callback) { | |
let counter = 0, | |
failed = 0, | |
errorList = []; | |
console.log("Starting the program"); | |
/** | |
* | |
* @param {any} expected | |
* @param {any} actual | |
* @returns {void} | |
*/ | |
const assert = (expected, actual) => { | |
counter++; | |
if (expected !== actual) { | |
failed++; | |
errorList.push(new Error(`Expected ${expected} but got ${actual}`)); | |
} | |
}; | |
callback(assert); | |
console.log(`Total tests: ${counter}, Failed: ${failed}`); | |
if (failed > 0) { | |
console.log("Errors:"); | |
errorList.forEach((err) => console.log(err.message)); | |
} | |
} | |
void (function () { | |
assement("questionMark", (assert) => { | |
assert( | |
["EEE", "EEU", "EUE", "EUU", "UEE", "UEU", "UUE", "UUU"], | |
questionMark("???") | |
); | |
assert(["EEU", "EUU", "UEU", "UUU"], questionMark("??U")); | |
assert(["foE", "foU"], questionMark("fo?")); | |
}); | |
console.log("Program finished"); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment