Skip to content

Instantly share code, notes, and snippets.

@valin4tor
Created May 15, 2018 08:19
Show Gist options
  • Save valin4tor/b87d3c62fd164d87951479919b2dfec5 to your computer and use it in GitHub Desktop.
Save valin4tor/b87d3c62fd164d87951479919b2dfec5 to your computer and use it in GitHub Desktop.
Algorithm Challenge Week 28 individual task
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
const digits = {
'1': /O.*N.*E/,
'2': /T.*W.*O/,
'3': /T.*H.*R.*E.*E/,
'4': /F.*O.*U.*R/,
'5': /F.*I.*V.*E/,
'6': /S.*I.*X/,
'7': /S.*E.*V.*E.*N/,
'8': /E.*I.*G.*H.*T/,
'9': /N.*I.*N.*E/
};
rl.question('Enter a word: ', answer => {
let containsDigit = false;
for (const i in digits) {
if (answer.match(digits[i])) {
console.log(i);
containsDigit = true;
}
}
if (!containsDigit) {
console.log('NO');
}
rl.close();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment