# Chef and Digits of a number

https://www.codechef.com/viewsolution/15109475
My solution for Chef and digits of a number.Please tell me why i am getting a WA.I have tried all kinds of inputs and the output seems to be correct.PLEASE HELP!!

Try this basic test case-

Input
1
1
No
Expected Output
Yes (we can flip that 1 and get entire string 0)

Further, I heard that using goto statements isnt exactly a good programming practice.

Small mistakes.

1. Constraints on n = 10^5.
But your input takes less than 10^5 chars,[ for( i = 0; i < 100000; i++) ],
which should have been [ for( i = 0; i < (some number greater than 10^5); i++) ]

2. Variable ‘total’ must have been initialized to 0.

Here is AC version after modifying your code.

1 Like

someone give the code

Umm my IDE shows output Yes.Can you please check it again?

Its giving No in codechef IDE, due to this- else if(one==0 || zero==0){printf("No\n");}

My IDE uses gcc 7.0 beta version.Is it because of that?

Not sure, but try running and compiling it in codechef IDE.

The codechef IDE is messed up.I tried printing the value of “one” when my input string was only 1.it outputted 100000…
Printed the same value in my Dev C++ IDE and it outputs 1.

It means your code is messing up somewhere. Sometimes, the IDEs we use kind of spoonfeed us by automatically fixing some erros/behaving in a way that our error doesnt affect the procedure. I will have a more detailed look at your code (if you modified code, please give a link )

EDIT- Did you remembered to give a new line character at the END of input? Because without it your logic fails since theres no newline char after string.

Thanks a lot @sumedhk.Appreciate the help.