brute force for me so far.
const readline = require('readline'); function foregone() { let argumentsArray = [], answerArray = []; let linecounter = 0, tests; const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); rl.on('line', (line) => { linecounter++; if(linecounter === 1) tests = line; else { argumentsArray.push(line); if(linecounter > tests) rl.close(); } }).on('close', () => { for(let i=0; i< argumentsArray.length; i++) { answerArray.push(noFours(argumentsArray[i])); } for(let i=0; i<answerArray.length; i++) { console.log(`Case #${i+1}: ${answerArray[i][0]} ${answerArray[i][1]}`) } process.exit(0); }); function noFours(num) { let a = num - 1, b = num - a; while(a.toString().indexOf('4') !== -1 || b.toString().indexOf('4') !== -1 && a >= b) { a--, b++; } if(a.toString().indexOf('4') === -1 && b.toString().indexOf('4') === -1) return [a, b]; else return undefined } }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
brute force for me so far.