instead of worrying bout size of the code, is it not better to worry about it's space and time complexity even more?
instead of worrying bout size of the code, is it not better to worry about it's space and time complexity even more?
It is not who I am inside but what I do that defines me.
And write the rest of the program in Perl. You'll be surprised to see how small you can go in there.Code:int main(void) { system("main.pl"); return 0; }
Check out my sig. Guess what it does. 63 characters including newline... shortest known.
If you want people around you to stop making sarcastic and snide remarks, go work for an embedded systems manufacturer. People will actually endorse your viewpoints and your efforts will be appreciated!
Last edited by jafet; 10-14-2006 at 01:54 AM.
Code:#include <stdio.h> void J(char*a){int f,i=0,c='1';for(;a[i]!='0';++i)if(i==81){ puts(a);return;}for(;c<='9';++c){for(f=0;f<9;++f)if(a[i-i%27+i%9 /3*3+f/3*9+f%3]==c||a[i%9+f*9]==c||a[i-i%9+f]==c)goto e;a[i]=c;J(a);a[i] ='0';e:;}}int main(int c,char**v){int t=0;if(c>1){for(;v[1][ t];++t);if(t==81){J(v[1]);return 0;}}puts("sudoku [0-9]{81}");return 1;}
let me get it straight...
This one is meant for a prg which chk the source code length...
i have 2 question...soln for 1st one was..
(91 characters) which got accepted...Code:a,t=10,c;main(){while(t--){c=1;while((a=getchar())&64)c<<=(a&7)==4|a==70;printf("%d ",c);}}
but for the 2nd question
(84 char)this works but if i remove "return 0;" it doesnt work i want to know why thats it...Code:#define b scanf("%d",& t,a,n; main(){ for(b t);t--;a+=n*(n>0)) b n); printf("%d",a); return 0;}
In first case i didnt hv return 0; and it worked
but in second if i didnt hv return 0; it is not working why is it so...
But my question is why do u want to write the whole code which in just one line, which looks so messy and which is not recommended
ssharish2005
Stupidity rules
"The Internet treats censorship as damage and routes around it." - John Gilmore
Why would you write code like that ? To make it difficult for everyone but you to understand it ?Code:#define b scanf("%d",& t,a,n; main(){ for(b t);t--;a+=n*(n>0)) b n); printf("%d",a); return 0;}
Teacher: "You connect with Internet Explorer, but what is your browser? You know, Yahoo, Webcrawler...?" It's great to see the educational system moving in the right direction
I think he wants to show someone how "good" program can be done in one line.
"The Internet treats censorship as damage and routes around it." - John Gilmore
Perhaps. But it doesn't make him 1337.
Teacher: "You connect with Internet Explorer, but what is your browser? You know, Yahoo, Webcrawler...?" It's great to see the educational system moving in the right direction
Cmon its not like that...its a contest question(http://spoj.pl challenge problem)...and they check the efficency of ur code length and obviously right answer too...thatsy...
and btw nobody answered my question...???!!!
Are they checking efficiency or code length ?
Because your code length doesn't affect efficiency.
Teacher: "You connect with Internet Explorer, but what is your browser? You know, Yahoo, Webcrawler...?" It's great to see the educational system moving in the right direction
ITS just code length....So whats the answer for my question...???why the 2nd soln requires "return 0;"
I'd say it's because most compilers default main as an int function, hence it expects it to return an integer value. The question rather should be why you didn't get a warning when you didn't have return....
Teacher: "You connect with Internet Explorer, but what is your browser? You know, Yahoo, Webcrawler...?" It's great to see the educational system moving in the right direction
You should NOT give them that code, because removing return 0; and int main() may not be supported by every compiler. And if they compile it and it won't compile, then you're eliminated, am I right?
"The Internet treats censorship as damage and routes around it." - John Gilmore
I think, it's just stupid to measure code lenght in lines/characters. So if I chose to use descriptive names, that would automatically make me lose? What they should be counting are the ;-s, how many instructions your code has - or something coding related for that matter.
What does this mean in the code: a,t=10,c; ?
@anon..
the c file automatically takes the variables declared as integer type...
@maxorator
the code gets complied but gives a NZEC a non zero error code...and also the output is right...