Re: C Contest...

From: Arthur J. O'Dwyer (ajo_at_nospam.andrew.cmu.edu)
Date: 03/21/05


Date: Mon, 21 Mar 2005 17:01:00 -0500 (EST)


On Thu, 17 Mar 2005, Aaron wrote:
>
> A long time ago my brother and I had a contest to see who could write the
> smallest card shuffler. I won with 316 bytes. (keystrokes). Below is the
> source.
>
> Can anybody beat it?

   Given that your "shuffling" algorithm produces the same output each
time it's run --- and not a very "random-looking" one at that --- and
even if you seed the RNG differently, you still get only 52 different
outcomes, I think it's perfectly reasonable to submit

   #include <stdio.h>
   int d[52];int main(){char*c[]={"Ace","2","3","4","5","6","7","8","9",
   "10","Jack","Queen","King","Diamonds","Spades","Hearts","Clubs"},i,j;
   for(i=0;i<52;++i)d[i]=i*9%52,printf("%s of %s\n",c[i*9%13],c[i*9/13%4
   +13]);return 0;}

247 characters, counting the three extraneous newlines.
   The fun of C golf is in doing /interesting/ things, though!
Make a 316-character C program that actually randomizes an array,
instead of just printing long strings of text, and you've got
something.

-Arthur



Relevant Pages

  • Re: C Contest...
    ... Aaron scribbled on the stall wall: ... > A long time ago my brother and I had a contest to see who could write the ...
    (alt.comp.lang.learn.c-cpp)
  • Re: C Contest...
    ... In article, Aaron ... >A long time ago my brother and I had a contest to see who could write the ... For project ideas and contributions: http://www.spellen.org/youcandoit/projects ...
    (alt.comp.lang.learn.c-cpp)
  • Re: C Contest...
    ... Aaron wrote: ... > A long time ago my brother and I had a contest to see who could write the ... int p,s,d; ...
    (alt.comp.lang.learn.c-cpp)
  • Re: SCWC 51
    ... acknowledging Max's lesser known brother as the ... protagonist of the winning clue. ... I now declare open the 51st edition of this contest. ... reason for this word; it just happened to pop into my head: ...
    (rec.puzzles.crosswords)
  • Re: Brno race - ... SPOILERS
    ... I met his brother a few weeks ago at the Seattle 100. ... Yates is hysterical, we had a charity auction/dinner and I had Yates laughing and dancing around like Tony Fania at Daytona, flipping me off with both hands! ... Oops change Aaron above to Anthoy. ...
    (rec.motorcycles.racing)