here is the code,I know it is the first and the most primary solution, but why
it fails (passes first two sets and fails on third)?
######## The Code ##########
const readline = require('readline');
var rl = readline.createInterface(process.stdin, process.stdout);
var TCNum=0;
var TCmax=null;
var waitFor='T';
rl.on('line', function(data) {
if(waitFor=='T'){
TCmax=parseInt(data);
waitFor='N';
}else if(waitFor=='N'){
var N=data;
var a='';
for(var i=0;i<N.length;i++)
{
if(N.substr(i,1)=='4')
{
a+='2';
}else{
a+='0';
}
}
console.log("Case #"+(TCNum+1)+": "+(parseInt(a)).toString()+'
'+(parseInt(N)-parseInt(a)).toString());
checkCount();
}
function checkCount()
{
TCNum++;
if(TCNum==TCmax)
{
rl.close();
}
}
}).on('close',function(){
process.exit(0);
});
###########################
--
You received this message because you are subscribed to the Google Groups
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-code/a47c0702-f03e-468f-9556-0d6855a7aa46%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.