[kw-pm] Last night's meeting

Daniel R. Allen da at coder.com
Fri Jun 19 08:24:50 PDT 2009


On Fri, 19 Jun 2009, John Macdonald wrote:

> So what is the best non-cheating char count?
>
> $ perl -e '@a=<>;print at a[rand(@a)]' <alpha.html

Unfortunately, that breaks the original problem spec; Abram specified
during the meeting that we couldn't read the whole stream at once and
get a random line from it.

The written spec doesn't exactly make that clear, admittedly. But the fun
for the first few minutes was learning the algorithm for a uniformly
random result from just storing one line.

-D

>
> That's better than the "cheating" we've been doing using -n!
>
> And then, it can be golfed down a bit more to:
>
> $ perl -e 'print at a[rand(@a=<>)]' <alpha.html
>
>
> So, that's down to 18 chars, with no supporting cheats of any kind.
> _______________________________________________
> kw-pm mailing list
> kw-pm at pm.org
> http://mail.pm.org/mailman/listinfo/kw-pm
>




More information about the kw-pm mailing list