Seems this question is eligible to be certified as a code golf problem!
ali.S · 2012-09-21 17:20:39
you left a room for furthor improvement in your code! now it's only 69!
for(;c+=a=getchar()-10;c=a?c-38:printf("%d\n",--c%9+1)*0);
N@53R · 2013-03-27 20:52:38
Hi It's a new version of your code only 68 char !!! :D It's works fine. but both versions of your code give Time Limit Exceeded !!! now :|
c;main(a){for(;c+=a=getchar()-10;c=a?c-2:printf("%d\n",--c%9+1)*0);}
ali.S · 2013-10-21 18:48:27
N@53R said:
Hi It's a new version of your code only 68 char !!! :D It's works fine. but both versions of your code give Time Limit Exceeded !!! now :|
c;main(a){for(;c+=a=getchar()-10;c=a?c-2:printf("%d\n",--c%9+1)*0);}
there is just a small mistake you made, when the user inputs "0\n" you first read "0". in your code after first iteration variable c will be equal to 36 (while in mine, it's 0). then you read "\n" and the result of the assignment will become 36. it's not 0 so the for will continue, and your program does not exit.
- 1
- 2