in reply to Golf: Pandigital puzzle
Just to get it started, he's a minor improvement:
#!/usr/bin/perl -l ($n,$N) = @ARGV; for (1 .. $N) { my %h; $h{int rand 10}++ for 1 .. $n; $g++ if keys %h > 9; } print $g/$N;
Update: here's another minor improvement on that:
#!/usr/bin/perl -l ($n,$N) = @ARGV; for (1 .. $N) { %h = map { int rand 10, "" } 1 .. $n; $g++ if keys %h > 9; } print $g/$N;
Cheap update: removing the whitespace:
#!/usr/bin/perl -l ($n,$N)=@ARGV; for(1..$N){ %h=map{int rand 10,""}1..$n; keys%h>9&&$g++ } print$g/$N;
Yet another (and hopefully final) update: here are the counts, as reported by the golfcount program:
145: itub 121: revd1 117: revd2 87: revd3
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Golf: Pandigital puzzle
by tilly (Archbishop) on Nov 18, 2004 at 23:20 UTC | |
by itub (Priest) on Nov 18, 2004 at 23:36 UTC | |
by itub (Priest) on Nov 19, 2004 at 01:28 UTC |