No, it's a command-line one-liner.... perl -e 'srand;push(@c,0)foreach(0..53);foreach(1..1e4){@d=(); foreach(0..53){$e{$_}=1;}foreach(0..5){$i=int(rand(54));while (!$e{$i}){$i=int(rand(54));} push(@d,$i);$e{$i}=0;} foreach(@d){$c[$_]++}}foreach(sort{$c[$b]<=>$c[$a]}0..$#c) {print $_+1," ",$c[$_],", ";}'

It also prevents duplicates per drawing. Explaining how it works and where they got it is left as an exercise to the student (as this smells a bit like homework)....

Update 22 Feb 2005: Fixed small typos, added a few spaces into code.

Update 22 Feb 2005: The code above appears to run in just under 1.0s, according to time(1), and weighs in around 267c total (256c for the code).


In reply to Re^2: Messing Around by atcroft
in thread Messing Around by Perl12

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.