Alternate subtitle: Ruby is small, Java is hueg
Here's the site: http://golf.shinh.org/
It's pretty simple, write code that produces the correct output for each input and make it as short as possible; your score is equal to the number of bytes in your program and, like golf, the lower the better. It has interpreters for a ridiculous number of languages (c,java,python,ruby,php,even befunge) so if you already know how to code yours is probably supported.
I've been dabbling in a bit, only know Java though so all my solutions are enormous, haha. I don't mind though because it's all relative, and if I can make things short in Java I'm learning the same type of thinking I'll need for terseness in any language.
The oldest problems are at the top, the newest are at the bottom. You can submit to any of them but you may as well start with the newest or any that catch your eye.
You can add your own problems, but for the love of god don't screw up the sample input/output. Also, make sure at least one of the samples requires a large amount of output compared to how much you'll need to write for a valid solution so that an 'embedded' program where the output is hardcoded isn't the shortest way.
To start things off, here's my definitely-not-optimal solution for 'numof 1 bits in 0 to 255' using java:
Here's the site: http://golf.shinh.org/
It's pretty simple, write code that produces the correct output for each input and make it as short as possible; your score is equal to the number of bytes in your program and, like golf, the lower the better. It has interpreters for a ridiculous number of languages (c,java,python,ruby,php,even befunge) so if you already know how to code yours is probably supported.
I've been dabbling in a bit, only know Java though so all my solutions are enormous, haha. I don't mind though because it's all relative, and if I can make things short in Java I'm learning the same type of thinking I'll need for terseness in any language.
The oldest problems are at the top, the newest are at the bottom. You can submit to any of them but you may as well start with the newest or any that catch your eye.
You can add your own problems, but for the love of god don't screw up the sample input/output. Also, make sure at least one of the samples requires a large amount of output compared to how much you'll need to write for a valid solution so that an 'embedded' program where the output is hardcoded isn't the shortest way.
To start things off, here's my definitely-not-optimal solution for 'numof 1 bits in 0 to 255' using java:
Code:
class A{public static void main(String[]a){for(int i=0,j,k,l=256;i<l;i++){k=0;for(j=1;j<l;j*=2){if((i&j)>0)k++;}System.out.print(k);}}}








Comment