Go Back   Flash Flash Revolution > General Discussion > Chit Chat
Register FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
Old 04-22-2009, 04:00 AM   #1
Patashu
FFR Simfile Author
Retired StaffFFR Simfile Author
 
Patashu's Avatar
 
Join Date: Apr 2006
Location: we traced the call...it's coming from inside the house
Age: 33
Posts: 8,609
Send a message via AIM to Patashu Send a message via MSN to Patashu Send a message via Yahoo to Patashu
Default Codegolf: Write the shortest code you can

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:
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);}}}
__________________
Patashu makes Chiptunes in Famitracker:
http://soundcloud.com/patashu/8bit-progressive-metal-fading-world
http://img.photobucket.com/albums/v216/Mechadragon/smallpackbanner.png
Best non-AAAs: ERx8 v2 (14-1-0-4), Hajnal (3-0-0-0), RunnyMorning (8-0-0-4), Xeno-Flow (1-0-0-3), Blue Rose (35-2-0-20), Ketsarku (14-0-0-0), Silence (1-0-0-0), Lolo (14-1-0-1)
http://i231.photobucket.com/albums/ee301/xiaoven/solorulzsig.png
Patashu is offline   Reply With Quote
Old 04-22-2009, 04:15 AM   #2
Necamus
FFR Player
 
Necamus's Avatar
 
Join Date: Nov 2005
Age: 34
Posts: 853
Default Re: Codegolf: Write the shortest code you can

I made yours shorter instead of looking at the site, but only by two characters:

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);}}}
If a for loop is only executing a single line, you don't need curly brackets around that line.
__________________
www.freerice.com
Necamus is offline   Reply With Quote
Old 04-22-2009, 04:17 AM   #3
Patashu
FFR Simfile Author
Retired StaffFFR Simfile Author
 
Patashu's Avatar
 
Join Date: Apr 2006
Location: we traced the call...it's coming from inside the house
Age: 33
Posts: 8,609
Send a message via AIM to Patashu Send a message via MSN to Patashu Send a message via Yahoo to Patashu
Default Re: Codegolf: Write the shortest code you can

Ooh, thanks.

EDIT: Also, I undid an earlier attempt that added two bytes (allocating 256 to a variable, l) so now it's at 131:

Code:
class A{public static void main(String[]a){for(int i=0,j,k;i<256;i++){k=0;for(j=1;j<256;j*=2)if((i&j)>0)k++;System.out.print(k);}}}
__________________
Patashu makes Chiptunes in Famitracker:
http://soundcloud.com/patashu/8bit-progressive-metal-fading-world
http://img.photobucket.com/albums/v216/Mechadragon/smallpackbanner.png
Best non-AAAs: ERx8 v2 (14-1-0-4), Hajnal (3-0-0-0), RunnyMorning (8-0-0-4), Xeno-Flow (1-0-0-3), Blue Rose (35-2-0-20), Ketsarku (14-0-0-0), Silence (1-0-0-0), Lolo (14-1-0-1)
http://i231.photobucket.com/albums/ee301/xiaoven/solorulzsig.png

Last edited by Patashu; 04-22-2009 at 04:21 AM..
Patashu is offline   Reply With Quote
Old 04-22-2009, 05:16 AM   #4
leonid
I am leonid
Retired StaffFFR Simfile AuthorFFR Music ProducerD7 Elite KeysmasherFFR Veteran
 
leonid's Avatar
 
Join Date: Oct 2008
Location: MOUNTAIN VIEW
Age: 35
Posts: 8,080
Default Re: Codegolf: Write the shortest code you can

Dude, that's way too nerdy.
__________________



Proud member of Team No
leonid is offline   Reply With Quote
Old 04-22-2009, 05:21 AM   #5
funmonkey54
The Chill Keeper
FFR Veteran
 
funmonkey54's Avatar
 
Join Date: Oct 2007
Posts: 4,127
Send a message via AIM to funmonkey54
Default Re: Codegolf: Write the shortest code you can

Oh wow. This is awesome!
__________________

funmonkey54 is offline   Reply With Quote
Old 04-22-2009, 05:40 AM   #6
Patashu
FFR Simfile Author
Retired StaffFFR Simfile Author
 
Patashu's Avatar
 
Join Date: Apr 2006
Location: we traced the call...it's coming from inside the house
Age: 33
Posts: 8,609
Send a message via AIM to Patashu Send a message via MSN to Patashu Send a message via Yahoo to Patashu
Default Re: Codegolf: Write the shortest code you can

it's okay, I teach advanced theory about placing coloured arrows to music and then play them, I already have my nerd quotient filled out
__________________
Patashu makes Chiptunes in Famitracker:
http://soundcloud.com/patashu/8bit-progressive-metal-fading-world
http://img.photobucket.com/albums/v216/Mechadragon/smallpackbanner.png
Best non-AAAs: ERx8 v2 (14-1-0-4), Hajnal (3-0-0-0), RunnyMorning (8-0-0-4), Xeno-Flow (1-0-0-3), Blue Rose (35-2-0-20), Ketsarku (14-0-0-0), Silence (1-0-0-0), Lolo (14-1-0-1)
http://i231.photobucket.com/albums/ee301/xiaoven/solorulzsig.png
Patashu is offline   Reply With Quote
Old 04-22-2009, 06:14 AM   #7
Kekeb
davai
FFR Veteran
 
Kekeb's Avatar
 
Join Date: Dec 2006
Age: 33
Posts: 2,765
Default Re: Codegolf: Write the shortest code you can

Interesting, I'll try my hand at a few later today.
I will probably end up using C# because I'm a fail boat.
Kekeb is offline   Reply With Quote
Old 04-22-2009, 10:25 AM   #8
Tokzic
FFR Player
 
Tokzic's Avatar
 
Join Date: May 2005
Location: TGB
Age: 34
Posts: 6,878
Send a message via AIM to Tokzic
Default Re: Codegolf: Write the shortest code you can

dammit, miranda isn't supported

just to show how cheap miranda is for this, the first one is

Code:
p="Hello, world!"
__________________

Last edited by Tokzic: Today at 11:59 PM. Reason: wait what
Tokzic is offline   Reply With Quote
Old 04-22-2009, 11:48 AM   #9
Flaming_Dingleberry
Everybody gets one.
FFR Veteran
 
Flaming_Dingleberry's Avatar
 
Join Date: Jul 2006
Location: Fuckin space bro
Posts: 1,008
Default Re: Codegolf: Write the shortest code you can

What in the God forsaken hell is this?
Flaming_Dingleberry is offline   Reply With Quote
Old 04-22-2009, 11:50 AM   #10
AC1speakerbox
FFR Player
FFR Veteran
 
AC1speakerbox's Avatar
 
Join Date: Jun 2006
Age: 32
Posts: 1,242
Send a message via AIM to AC1speakerbox Send a message via MSN to AC1speakerbox
Default Re: Codegolf: Write the shortest code you can

^ I lol'd
This really is ridiculous
AC1speakerbox is offline   Reply With Quote
Old 04-22-2009, 12:02 PM   #11
Oni-Paranoia
No fucks
FFR Veteran
 
Oni-Paranoia's Avatar
 
Join Date: Dec 2006
Location: Everywhere
Posts: 2,440
Default Re: Codegolf: Write the shortest code you can

I wanna be a nerd!!

Code:
shutdown -s -t 2 -c "Hi Patashu"
I'm pro now right?
Oni-Paranoia is offline   Reply With Quote
Old 04-22-2009, 12:08 PM   #12
AC1speakerbox
FFR Player
FFR Veteran
 
AC1speakerbox's Avatar
 
Join Date: Jun 2006
Age: 32
Posts: 1,242
Send a message via AIM to AC1speakerbox Send a message via MSN to AC1speakerbox
Default Re: Codegolf: Write the shortest code you can

Code:
lol
win
AC1speakerbox is offline   Reply With Quote
Old 04-22-2009, 03:40 PM   #13
PsYcHoZeRoSk8eR
Network Security Analyst
FFR Simfile AuthorFFR Veteran
 
PsYcHoZeRoSk8eR's Avatar
 
Join Date: May 2004
Location: ɥɔʇɐdı sʞuɐɥʇ
Age: 36
Posts: 5,183
Send a message via AIM to PsYcHoZeRoSk8eR Send a message via MSN to PsYcHoZeRoSk8eR
Default Re: Codegolf: Write the shortest code you can

This is cool, but I hate programming. After working in assembly, I hope to never have to work with it again.
__________________

Quote:
Originally Posted by Lightdarkness
I'm light f**king darkness
PsYcHoZeRoSk8eR is offline   Reply With Quote
Old 04-22-2009, 05:36 PM   #14
Ruritsu
FFR Player
 
Join Date: Mar 2008
Posts: 479
Default Re: Codegolf: Write the shortest code you can

Purely awesome, I'll try my hand at it...
__________________
=__=' My sig was 22 pixels too tall, so this is here instead...
Ruritsu is offline   Reply With Quote
Old 04-22-2009, 05:53 PM   #15
Kekeb
davai
FFR Veteran
 
Kekeb's Avatar
 
Join Date: Dec 2006
Age: 33
Posts: 2,765
Default Re: Codegolf: Write the shortest code you can

I tried my hand at the Hexagon problem, but I finished at 80 lines (not stacked, but rofl massive), and with it being very inefficient.
EDIT: How do I shot algorithms.

Last edited by Kekeb; 04-22-2009 at 06:24 PM..
Kekeb is offline   Reply With Quote
Old 04-22-2009, 05:58 PM   #16
chidori!
FFR Player
 
chidori!'s Avatar
 
Join Date: Jun 2007
Location: 「Gensekyo」
Age: 29
Posts: 1,603
Send a message via MSN to chidori! Send a message via Yahoo to chidori!
Default Re: Codegolf: Write the shortest code you can

<h1>Do i win?</h1>
EDIT: wait no this //
do i win now?

Last edited by chidori!; 04-22-2009 at 06:09 PM..
chidori! is offline   Reply With Quote
Old 04-22-2009, 07:52 PM   #17
Patashu
FFR Simfile Author
Retired StaffFFR Simfile Author
 
Patashu's Avatar
 
Join Date: Apr 2006
Location: we traced the call...it's coming from inside the house
Age: 33
Posts: 8,609
Send a message via AIM to Patashu Send a message via MSN to Patashu Send a message via Yahoo to Patashu
Default Re: Codegolf: Write the shortest code you can

Quote:
Originally Posted by Kekeb View Post
I tried my hand at the Hexagon problem, but I finished at 80 lines (not stacked, but rofl massive), and with it being very inefficient.
EDIT: How do I shot algorithms.
It's tricky, but you should be able to express its arithmetic in just a few nested functions, abusing % and substrings and stuff
__________________
Patashu makes Chiptunes in Famitracker:
http://soundcloud.com/patashu/8bit-progressive-metal-fading-world
http://img.photobucket.com/albums/v216/Mechadragon/smallpackbanner.png
Best non-AAAs: ERx8 v2 (14-1-0-4), Hajnal (3-0-0-0), RunnyMorning (8-0-0-4), Xeno-Flow (1-0-0-3), Blue Rose (35-2-0-20), Ketsarku (14-0-0-0), Silence (1-0-0-0), Lolo (14-1-0-1)
http://i231.photobucket.com/albums/ee301/xiaoven/solorulzsig.png
Patashu is offline   Reply With Quote
Old 04-22-2009, 11:05 PM   #18
Crashfan3
FFR Player
 
Crashfan3's Avatar
 
Join Date: Nov 2006
Location: Jefferson, Ore.
Age: 32
Posts: 2,937
Send a message via AIM to Crashfan3 Send a message via Skype™ to Crashfan3
Default Re: Codegolf: Write the shortest code you can

I only know a little bit of Java.
I'm more fluent in VB... so, yeah, I'll just leave this thread before I get humiliated...
__________________
Crashfan3 is offline   Reply With Quote
Old 04-22-2009, 11:13 PM   #19
Izzy
Snek
FFR Simfile AuthorFFR Veteran
 
Izzy's Avatar
 
Join Date: Jan 2003
Location: Kansas
Age: 34
Posts: 9,192
Default Re: Codegolf: Write the shortest code you can

I might try it for c#.
Izzy is offline   Reply With Quote
Old 04-23-2009, 12:12 PM   #20
danthemano
FFR Player
 
danthemano's Avatar
 
Join Date: Mar 2008
Location: North
Age: 32
Posts: 263
Default Re: Codegolf: Write the shortest code you can

quite interesting, tho it makes me feel like a total noob.
*pretends he knows 'code speak'...
__________________
Quote:
Originally Posted by MrDespair View Post
You have some issues regarding to unhygienic anger, putting bodywaste on people? Could i suggest you try some Manga?
danthemano is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 09:22 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright FlashFlashRevolution