7
\$\begingroup\$

I just looked and saw that there are 399 questions on this wondrous "Programming Puzzles & Code Golf" site!!! That means that...THIS IS THE 400th question!!! To celebrate this momentous occasion, here are your goals:

  1. Write a piece of code that is EXACTLY 400 bits.

    • That's right...BITS!!!
    • For the risk of redundancy and the sake of clarity, that's 50 bytes!!!
  2. Because this occasion is so extraordinarily meaningful, each bit and therefore each byte must also be meaningful!

    • In other words: You can't just name a variable aaaaa because you needed 32 extra bits to get to 400. However, you can rename it to party as long as that is a meaningful name for that variable.
  3. Your program must do something appropriate (not necessarily output something appropriate) to celebrate this grand occasion!

    • For example: You could choose to make a program that outputs 400. However, I must needs state that although submitting code that does only that would meet this requirement, it would also be like celebrating your birthday party at home by yourself sick in bed. At least you celebrated, but hey: You can do better!!!
  4. The most creative code wins!!! In this case, creativity will be measured by votes.

  5. This contest will last until 400 users have viewed this question. If there is a tie when the 400th user views this question, the contest will go into sudden-death overtime until there is a clear winner


Oh, and lest I forget...HAPPY 400th QUESTION!!!

\$\endgroup\$

closed as off-topic by Martin Ender Nov 21 '16 at 10:58

  • This question does not appear to be about programming puzzles or code golf within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • \$\begingroup\$ I added the tag code-shuffleboard, as someone suggested on meta. \$\endgroup\$ – Joey Adams Aug 12 '11 at 22:50
  • \$\begingroup\$ it's not the 400th question anymore :( \$\endgroup\$ – ratchet freak Aug 13 '11 at 2:15
  • \$\begingroup\$ 20 Users to go! Get your votes in! \$\endgroup\$ – Briguy37 Aug 24 '11 at 18:18
  • 2
    \$\begingroup\$ I think I'm the 400th viewer. \$\endgroup\$ – zzzzBov Aug 25 '11 at 18:35
  • 1
    \$\begingroup\$ I'm closing this question as off-topic because rules 2 and 3 do not constitute objective validity criteria. \$\endgroup\$ – Martin Ender Nov 21 '16 at 10:58

14 Answers 14

10
\$\begingroup\$

Python, FOUR HUNDRED bits

i=0
while 1:print" "*(i%8>3 and-i%4 or i%4),0;i+=1

At first I wanted to make a sine scroller, but there was no place for the import. Now you get a bugged triangle wave. ~~~party~~~

\$\endgroup\$
  • \$\begingroup\$ Fixed version: while 1:print" "*[i%8,-i%4 or 4][i%8>3],0;i+=1 \$\endgroup\$ – JBernardo Dec 30 '13 at 0:11
8
\$\begingroup\$

Brainf*ck

[-]>++++[<+++++++++++++>-]<.----..---------------.

And the output will be: 400!

\$\endgroup\$
7
\$\begingroup\$

Ruby

1.upto(side=gets.to_i){|i|puts (?**i).center side}

This creates a wobbling tree, like the following:

   *   
  **   
  ***  
 ****  
 ***** 
****** 
*******
\$\endgroup\$
7
\$\begingroup\$

Scala gratulates with 400 Bits:

(1 to 400).map(x=>print("""
 ,
|_|
"""))

Sample:

 ,
|_|

 ,
|_|

 ,
|_|

 ,
|_|

... due to restrictions, I couldn't light bigger candles. I try to compensate with the scheer number.

\$\endgroup\$
  • \$\begingroup\$ By my count that is only 304 bits (38 Bytes). This question will have to take a DEEP breath to blow out all these candles, though...Nice! \$\endgroup\$ – Briguy37 Aug 15 '11 at 15:30
  • \$\begingroup\$ You're right, I picked the wrong variant, which only had 39 Bytes (38?), but had the problem, that the lower candles melted the upper ones. We absolutely need a bigger vertical distance to prevent London-like-lightenings. \$\endgroup\$ – user unknown Aug 15 '11 at 16:13
  • 1
    \$\begingroup\$ Here's a variation with 400 bits and 400 candles in a square: for(i<-1 to 20;x<-Seq(" , ","|_| "))println(x*20) :) \$\endgroup\$ – Luigi Plinge Nov 20 '11 at 2:48
  • \$\begingroup\$ you lost a blank: for(i<-1 to 20;x<-Seq(" , ","|_| "))println(x*20) - oh, I lost it too! A bug? \$\endgroup\$ – user unknown Nov 21 '11 at 12:19
5
\$\begingroup\$

JavaScript, 400 bits

Code

for(i=0,a='';i<400;)a+='\n!'+i++;alert(a+"\n400!")

Output

!0
!1
!2
!3
..
..
!398
!399
400!

Or, how it is read in English: "not 0, not 1, not 2, not 3 .. not 398, not 399, 400!"

Update

Just realized I forgot to attach the Fiddle for this problem!

\$\endgroup\$
2
\$\begingroup\$

HTML

(bad HTML!)

<marquee style="font-size:400px">~!400!~</marquee>
\$\endgroup\$
1
\$\begingroup\$

Python

50 characters or 400 bits as metered by other submissions.

i,j=1,1
while len(str(i))<81:
 print i 
 i,j=j,i+j

Simple fibonacci calculator, which terminates once the output no longer fits in a standard 80x60 terminal. Not especially festive I know, but the best I could come up with on short notice. More to follow!

\$\endgroup\$
1
\$\begingroup\$

Here comes C#!

class P{static void Main(){System.Console.Write("400!");}}

Ok, that is the smallest, running / valid, and remarkable thing i could squeeze out of .NET! But it fails by 13bytes! (code is 63bytes). Someone might suggest an improvement :D

Maybe using the roman numeral version might slash off an extra byte :-)

class P{static void Main(){System.Console.Write("CD!");}}
\$\endgroup\$
1
\$\begingroup\$

Bits of code, or bits compiled? Ah well, I see nobody has posted any x86 yet, so here goes...

x86

4D 5A 90 00 03 00 00 00 40 00 00 0F FF F0 00 0B 80 00 00 00 00 00 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

IDK if this counts, it's the first 400 bits (in hex) of a Win32 PE executable

VB.NET

Sub Main()
    Console.WriteLine("400 CodeGolf")
End Sub
\$\endgroup\$
1
\$\begingroup\$

Yet another Python answer.

k=(1,)
while len(k)<400:k+=(sum(k[-2:]),)
print(k)

Print the first 400 Fibonacci numbers. I notice one of the other Python answers also does the Fibonacci sequence... Oh well. I came up with this method of calculating Fibonacci numbers while working on another code golf and I thought it was neat so I figured I'd answer anyway.

\$\endgroup\$
0
\$\begingroup\$

Ada

with P;procedure C is begin P("400! Yay!");end C;

assuming there is a package p:

$ cat p.ads
procedure P(S:String);
$ cat p.adb
with Ada.Text_IO;
procedure P(S:String) is
begin
   Ada.Text_IO.Put_Line(S);
end P;

If I put with Text_IO; and Text_IO.Put("") into the source code I would already exceed the limit by 7 bytes, without outputting anything.. Ada is hard to golf.

\$\endgroup\$
  • \$\begingroup\$ I put in a clarification to the question so you don't have to worry about importing input/output libraries. Hope this helps! \$\endgroup\$ – Briguy37 Aug 15 '11 at 15:20
0
\$\begingroup\$

Shells with banner installed

banner -w80 HAPPY  HAPPY  HAPPY  400th  QUESTION!
\$\endgroup\$
0
\$\begingroup\$

Perl

$number_400=400;
$and_still_number_400=$still_number_400*4/4;
$when_is_the_500_post="In 100 posts!!";
print $number_400*400/400;

#      # ########## ##########
#      # #        # #        #
#      # #        # #        #
######## #        # #        #
       # #        # #        #
       # #        # #        #
       # #        # #        #
       # ########## ##########       
\$\endgroup\$
  • \$\begingroup\$ This solution isn't the required length (400 bits). \$\endgroup\$ – Joey Adams Aug 20 '11 at 4:21
  • \$\begingroup\$ On my computer, it shows up exactly 400 bits. \$\endgroup\$ – Dynamic Aug 20 '11 at 13:46
  • 1
    \$\begingroup\$ you mean 400 bytes? \$\endgroup\$ – bcc32 Aug 24 '11 at 17:43
  • \$\begingroup\$ @bcc32: My laptop says 400 bits. IDK what is wrong. \$\endgroup\$ – Dynamic Aug 24 '11 at 18:13
  • 3
    \$\begingroup\$ That's one modern laptop you got there, we're still stuck with 64bit CPU's... :( \$\endgroup\$ – st0le Aug 26 '11 at 10:59
0
\$\begingroup\$

Perl /*Life:Eat,sleep,then die */

$rip=400;$pork="Pi";chop($pork);sleep($rip);die();
\$\endgroup\$
  • \$\begingroup\$ ...- is V, so currently it looks like it prints V000 400 times. \$\endgroup\$ – Briguy37 Aug 24 '11 at 18:23
  • \$\begingroup\$ Yup it surely does..'....-' = 4. Missed a dot. That exceeds my bit limit..back to the drawing board \$\endgroup\$ – zundarz Aug 24 '11 at 19:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.