http://www.perlmonks.org?node_id=408322


in reply to Golf: 3 hole golf game

human.pl: 103 strokes shuffle.pl: 37 strokes select.pl: 37 strokes ------------------------ total: 177 strokes
Although my human.pl is (sadly) a complete ripoff of Tilly's... I just changed the arbitrary limit to a silly but not arbitrary one. Also, no modules for #2 or #3.

human.pl :::::::::::::: @x=<>;$z=length"@x";%x=map{($x=lc)=~s/\d+/0 x($z-length$&).$&/ge;$_,$x}@x;print sort{$x{$a}cmp$x{$b}}@x :::::::::::::: select.pl :::::::::::::: @_=<>;print splice@_,rand@_,1for 1..2 :::::::::::::: shuffle.pl :::::::::::::: print splice@_,rand@_,1for 1..(@_=<>)

Frankly, I feel that this should count as a solution to #1, but it doesn't, because perl's native arithmetic comparison is just broken on ludicrously long numbers:

:::::::::::::: human_shoulda.pl :::::::::::::: print map{@$_}sort{$z=0;{$z>@$a?0:lc$$a[$z]cmp lc$$b[$z++]||$$a[$z]<=> +$$b[$z++]||redo}}map{[split/([\d\n]+)/]}<>

Oh, well. It's still longer than my cleaned-up version of Tilly's, so I guess it's no real loss.

------------ :Wq Not an editor command: Wq