in reply to Golf: Pandigital puzzle

Looks like I'm on 74 :-)

$N=pop;for(1..$N){%h=map{int rand 10,0}1..$ARGV[0];$g+=keys%h>9}print$ +g/$N

I must admit though that I stole the pop() trick from tilly.

Update: Actually not. The -l switch. 77.

Update 2: 76:

#!perl -l $N=pop;for(1..$N){$g+=keys%{{map{int rand 10,0}1..$ARGV[0]}}>9}print$g +/$N

Jenda
We'd like to help you learn to help yourself
Look around you, all you see are sympathetic eyes
Stroll around the grounds until you feel at home
   -- P. Simon in Mrs. Robinson

Replies are listed 'Best First'.
Re^2: Golf: Pandigital puzzle
by tilly (Archbishop) on Nov 19, 2004 at 02:37 UTC
    Let's tweak that down to 72:
    #!perl -l $N=pop;print 1/$N*grep{keys%{{map{int rand 10}1..$ARGV[0]*2}}>9}1..$N
      Further tweaking to 71
      print 1/($N=pop)*grep{keys%{{map{int rand 10}1..$ARGV[0]*2}}>9}1..$N

      Update: If I can change the order of the parameters, I can get to 70.
      $#a=2*pop;print 1/($N=pop)*grep{keys%{{map{int rand 10}@a}}>9}1..$N

      Being right, does not endow the right to be rude; politeness costs nothing.
      Being unknowing, is not the same as being stupid.
      Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
      Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.