Open Ircnet #perl Golf Challenge (finished)

The object of the Challenge is to solve a few programming tasks using the shortest programs you can think off

All programs must work on perl 5.6.1. (most likely programs you write on another version will be just fine, so don't directly go downloading a different perl)

All programs are filters. They must read input from STDIN, and send output to STDOUT. All input lines are properly newline terminated, and do not contain binary 0. All input files have a total size so that they will fit comfortably in memory and still allow you ample memory to play with.

All output lines must likewise be properly newline terminated. Nothing must appear on STDERR. The average runtime of the program must be finite, but may be arbitrarily long.

You must assume total memory is < 2**32 bytes (this e.g. implies sizes of arbitrary datastructures can be represented in a plain integer, and that you must not try to generate arbitrarily big datastructures).

The program must be written as one or more lines. The score for each hole is the total number of characters you need (smaller is better). If your program is more than one line, you must count the newlines inbetween as one character each. The #! line is not counted. If you use options on the #! line, the options themselves are counted, including the leading space and -

The program may only use the perl executable, no other executables on the system are allowed (in particular, you must not use the programs implementing the other holes. The program may use itself though). You may use any of the perl 5.6.1 standard core modules. Your solution must be portable in the sense that it should work on all versions of 5.6.1 everywhere (however, it's perfectly fine to abuse perl 5.6.1 bugs). You may assume ASCII as character set and must not use any of the unicode specific semantics

Current holes:

  1. "Human Sort"

    Sort a set of lines, but with a twist.

    When sorting a set of lines, humans like to see the numeric parts of a line sorted numerically and the alphabetical parts case insensitive. For the numeric parts you may ignore the possibility of negative numbers, floating point numbers and leading zeros, the numbers however are almost unconstrained in length. In other words, a sequence of one or more digits plays the same sort of role as some kind of single character, and such a sequence sorts before all normal letters, but among themselves they are ordered by numerical value. Example:

    1 < A < amstelveen < Amsterdam < Amsterdam5 < Amsterdam40 < Amsterdamned
    You are free in how you order e.g. fOo versus FoO or a digit versus space.

    Notes:

  2. "Fair Shuffle"

    Outputs some random permutation of the input lines. Each permutation must be equally likely over many runs.

  3. "Select Two"

    print 2 lines each randomly chosen from the input, however the two must not come from the same line in the input. You may assume the input is 2 lines or more. each pair of outputlines must be equally likely, and their order itself also random

Some more hints about randomness:

Here is a program to pre-screen your entries. Name your programs human.pl, shuffle.pl and select.pl respectively. The checking program may get new interesting cases added over time.

Clarifications may be added during the tournament, so don't forget to recheck this page ever so often

The deadline is now fixed at English newyear, 2002/01/01 00:00:00 UT

Please submit your solutions even if you haven't solved all holes yet or you think your entries are bad. Part of the fun of this kind of contest is to see how people and solutions evolve over time. (Solutions will be made public after the tournament).

If you are on Ircnet, /msg your solutions to ton-. Make sure he confirms that he saw it.

Or mail to perl-golf-0@ton.iguana.be (We'll assume mail doesn't fail unnoticed)

State if you consider yourself newbie or experienced. (If enough newbies enter, we'll have a separate pool for them)

Please don't publish your scores on individual holes. You are only supposed to know the best totals.

Final standing (people with valid entries for each hole):

And the winner is: Spiff, even though there were some last minute attempts to dislodge him, especially from Autrijus Tang who went from last place to third in the last few hours.

In retrospect I made three big mistakes when setting up this challenge:

Fortunately there was also some very interesting golfing on hole 1, so in the end it still turned out quite nicely.

Playing "Bob" was particularly enjoyable. I got to see all solutions, so I could take the best elements from any of them, combine them and add my own ideas and come up with some stuff none of the players saw (having to toil in isolation). In the beginning BoB did best on all holes, but in the end only kept the lead on hole 1.

So, here is a hole by hole account.

And finally, for your consideration, here are most entries: (non-rejected entries with the same score are in the order they arrived)

Assignment 1: human sort
 
J.Robert Suckling137sub x{$_=shift;$v="";while($_){if(/^(\D*)/){$v.=$&;$_=$'}if(/^(\d+)/){$v.=sprintf("%09d",$&),$_=$'}};$v}map{print}sort{x($a)cmp x($b)}<>; (rejected)
Autrijus Tang125sub K($$){@a=@_;$*=ord((sort+map{chr(length)}"@_"=~/\d+/g)[-1]);s/\d+/sprintf"%0$*s",$&/eg for@a;$a[0]cmp$a[1]}print+sort K<> (rejected)
Kye Leslie110-n $c++;$e=$_;s/(\d+)/$a=length $1;''x(9999-$a).$1/ge;$a{lc($_.$c)}=$e;}foreach $b(sort keys %a){print $a{$b}; (rejected)
Jonathan E. Paton108print/([^\0]*)$/for sort map{$b=$_;lc;$_=$`.0 x(length@b-length$&)."$&\0$'"while/\d+(?!.*\0)/;"$_\0$b"}@b=<> (rejected)
Kye Leslie105$c++;$e=$_;s/(\d+)/$a=length $1;' 'x(99-$a).$1/ge;$a{lc($_.$c)}=$e;}foreach$b(sort keys %a){print $a{$b}; (rejected)
Autrijus Tang91sub K($$){@a=@_;$*=length"@_";s/\d+/sprintf"%0$*s",$&/eg for@a;$a[0]cmp$a[1]}print+sort K<> (rejected)
Spifff90$;|=y===cfor@f=<>;sub f{$_=lc$_[0];s/\d+/sprintf"%$;s",$&/eg;$_}print+sort{f($a)cmp f$b}@f (rejected)
BoB85sub f{$_=pop;s/\d+/$a=$&+0;pack("N",length$a)."-$a"/eg;$_}print sort{f($a)cmp f $b}<> (rejected)
Autrijus Tang85print+sort{@_=($a,$b);$*=length"@_";s/\d+/sprintf"%0$*s",$&/eg for@_;$_[0]cmp$_[1]}<> (rejected)
Autrijus Tang81print+sort{s|\d+|0 x(length($a.$b)-length$&).$&|eg,for@_=($a,$b);$_[0]cmp$_[1]}<> (rejected)
Ronald J Kimball79print sort{($$_=lc${lc$_})=~s/\d+|$/$"x(1e4-length$&).$&/ge for A,B;$A cmp$B}<> (rejected)
Rick Klement79($a=uc)=~s/\d+/$|x($=-length$&).$&/eg,s/^/$a/for@l=<>;s/.*\n//,print for sort@l (rejected)
Autrijus Tang78print+sort{s|\d+|0 x(2**07-length$&).$&|eg,for@_=map{lc}$a,$b;$_[0]cmp$_[1]}<> (rejected)
Ronald J Kimball78print sort{($$_=lc${lc$_})=~s/\d+|$/$"x(99-length$&).$&/ge for A,B;$A cmp$B}<> (rejected)
Suo77print/(.*\n)$/for sort map{$x=$_;s#\d+#'0'.pack'w/a*',$&+0#eg;"\U$_\E\n$x"}<> (rejected)
Piers Cawley74print map/\n(.+)/s,sort map{($a=lc)=~s/\d+/$[.chr(length$&).$&/eg;"$a$_"}<> (rejected)
Andrew Savige74sub Z{$_=pop;s/\d+/0 .pack(N,length$&).$&/eg;uc}print sort{Z($a)cmp Z$b}<> (rejected)
Richard Proctor74-n $a=$_;s/\d+/sprintf"%099s",$&/ge;$b{$:.uc}.=$a}{print map{$b{$_}}sort%b (rejected)
Llasse73print sort{"$a$b"=~/^(.*\D)?(\d+).*\n\1(\d+)/i&&$2<=>$3||lc$a cmp lc$b}<> (rejected)
Suo73print/(.*\n)$/for sort map{$x=$_;s#\d+|\n#pack'xN/a*',$&#eg;"\U$_\E$x"}<> (rejected)
Autrijus Tang73print+sort{s|\d+|0 x(2**07-length$&).$&|eg,for@_=($a,$b);$_[0]cmp$_[1]}<> (rejected)
Andrew Savige73sub Z{s/\d+/0 .pack(N,length$&).$&/eg;uc}print sort{Z($_=$a)cmp Z$_=$b}<> (rejected)
Autrijus Tang73sub _{s|\d+|0 x(2**07-length$&).$&|eg;lc}print+sort{_($_=$a)cmp _$_=$b}<> (rejected)
Llasse72print sort{"$a$b"=~/^(.*\D)?(\d+).*\n\1(\d+)/i;$2<=>$3||lc$a cmp lc$b}<> (rejected)
Suo72print/(.*\n)$/for sort map{$x=$_;s#\d+|\n#pack'N/a*',$&#eg;"\U$_\E$x"}<> (rejected)
Piers Cawley72print map/\n(.+)/s,sort map{($a=lc)=~s/\d+/0${\chr length$&}$&/g;$a.$_}<> (rejected)
Andrew Savige71sub Z{$_=pop;s/(\d+)/sprintf"%.99d",$1/eg;uc}print sort{Z($a)cmp Z$b}<> (rejected)
Eugene van der Pijll70sub a{$_=pop;s#\d+#0 .pack'N/A*',$&#ge;lc$_}print sort{a($a)cmp a$b}<> (rejected)
Llasse70print sort{"$a$b"=~/^(.*)(\d+).*\n\1(\d+)/i&&$2<=>$3||lc$a cmp lc$b}<> (rejected)
Andrew Savige70sub Z{s/\d+/0 .pack(N,$+[0]).$&/eg;uc}print sort{Z($_=$a)cmp Z$_=$b}<> (rejected)
Llasse69print sort{"$a$b"=~/^(.*)(\d+).*\n\1(\d+)/?$2<=>$3:$a cmp$b}map lc,<> (rejected)
Andrew Savige69sub Z{s/\d+/(':'x length$&).$&/eg;uc}print sort{Z($_=$a)cmp Z$_=$b}<> (rejected)
BoB68print sort{"$a$b"=~/^(.*)(\d+).*\n\1(\d+)/i&&$2-$3||lc$a cmp lc$b}<> (rejected)
lasse68print sort{"$a$b"=~/^(.*)(\d+)(.*)\n\1(\d+)\3$/i?$2<=>$4:$a cmp$b}<> (rejected)
Eugene van der Pijll68sub a{$_=pop;s#\d+#0 .pack'N/A*',$&#ge;lc}print sort{a($a)cmp a$b}<> (rejected)
Eugene van der Pijll68sub a{$_=pop;s#\d+#_ x(length$&).$&#ge;lc}print sort{a($a)cmp a$b}<> (rejected)
BoB67print/.*\n$/gfor sort map{$x=$_;s#\d+|\n#pack'xN/a*',$&#eg;lc().$x}<> (rejected)
Andrew Savige67sub Z{s/\d+/0 .(A x$+[0]).$&/eg;uc}print sort{Z($_=$a)cmp Z$_=$b}<> (rejected)
Eugene van der Pijll66sub a{$_=lc pop;s#\d+#A x$+[0].$&#ge;$_}print sort{a($a)cmp a$b}<> (rejected)
Spiff65sub f{$_=pop;s;\d+;~0/3+$+[0].$&;eg;lc}print+sort{f($a)cmp+f$b}<> (rejected)
Eugene van der Pijll65sub a{$_=pop;s#\d+#8x$+[0].$/.$&#ge;lc}print sort{a($a)cmp a$b}<> (rejected)
Andrew Savige65sub Z{s/\d+/0 .A x$+[0].$&/eg;uc}print sort{Z($_=$a)cmp Z$_=$b}<> (rejected)
Andrew Savige65sub Z{$_=pop;s/\d+/length($&).$&/eg;uc}print sort{Z($a)cmp Z$b}<> (rejected)
Richard Proctor65-n $a=$_;s/\d+/sprintf"%99s",$&/ge;$b{$:.uc}.=$a}{print@b{sort%b} (rejected)
Autrijus Tang64-p $k=$_;s!|\d+!pack'AN/Z*',0,$&!eg;$;{lc,}.=$k}for(@;{sort%;}){ (rejected)
Andrew Savige64sub Z{s/\d+/': 'x$+[0].$&/eg;uc}print sort{Z($_=$a)cmp Z$_=$b}<> (rejected)
Andrew Savige64sub Z{s/\d+/':0'x$+[0].$&/eg;uc}print sort{Z($_=$a)cmp Z$_=$b}<> (rejected)
Eugene van der Pijll63sub a{$_=lc pop;s#\d+#0 x$&.$/#ge;$_}print sort{a($a)cmp a$b}<> (rejected)
Andrew Savige63sub Z{s/\d+/':'x$+[0].$&/eg;uc}print sort{Z($_=$a)cmp Z$_=$b}<> (rejected)
Autrijus Tang62-pa s!|\d+!pack'AN/Z*',0,$&!eg;$;{lc,}.="@F\n"}for(@;{sort%;}){ (rejected)
Autrijus Tang59sub _{$_=shift;s/\d+/chr$&/g;$_}print+sort{_($a)cmp _ $b}<> (rejected)
Ronald J Kimball58print sort{"$a$b"=~('(\D+)(\d*)\n'x 2);$1cmp$3||$2<=>$4}<> (rejected)
 
Dave Hoover357print sort{$r=0;$j=$a;$k=$b;$d=$j=~/\d/?1:0;until($r){$u=$v=1;$e=$d?'\d':'[a-z]';($p,$q)=map{s/^($e+)//i?lc$1:''}$j,$k;($x,$y)=map/\w/?0:1,$j,$k;if($p&&$q){if($d){($h,$i)=map{length}$p,$q;;if(!($r=($h<=>$i))){($u,$v)=map{s/(.)//?$1:''}$p,$q until($u==''||($r=$u<=>$v))}}$r=($p cmp$q)if!$d}else{$r=$p?1:-1;$r=!$r if$d}$r||($y&&$r++)||$x&&$r--;$d=$d?0:1}$r}<>
Dave Hoover301print sort{chop($j=$a);chop($k=$b);do{$e=($d=$j=~/^\d/)?'\d':'[a-z]';($p,$q)=map{s/^($e+)//i?lc$1:''}$j,$k;if($p&&$q){if($d&&!($r=length$p<=>length$q)){do{($u,$v)=map{s/(.)//?$1:''}$p,$q}until($u==''||($r=$u<=>$v))}$r=($p cmp$q)if!$d}else{$r=$p?1:-1;$r=!$r if$d}$r||(!$k&&$r++)||!$j&&$r--}until($r)}<>
Dave Hoover277$w='[a-z]';print sort{g($a,$b)}<>;sub g{my($j,$k,$z,$x)=@_;for($j,$k){my@c;{$e=/^\d/?'\d':$w;$p=$z?'':'+';s/($e$p)//i;push@c,lc$1;$1ne''&&redo}$_=+\@c}for(@$j){$v=$$k[$x++];last if$r=/\d/?$z?$_<=>$v:g($_,$v,1):$_ cmp$v}if($z){$r=($s=@$j<=>@$k)?$s:$r;$r=(grep/$w/,@$k)?-1:$r}$r}
Dave Hoover276$w='[a-z]';print sort{g($a,$b)}<>;sub g{my($j,$k,$z,$x)=@_;for($j,$k){my@c;{$e=/^\d/?'\d':$w;$p=$z?'':'+';s/($e$p)//i;push@c,lc$1;$1ne''&&redo}$_=\@c}for(@$j){$v=$$k[$x++];last if$r=/\d/?$z?$_<=>$v:g($_,$v,1):$_ cmp$v}if($z){$r=($s=@$j<=>@$k)?$s:$r;$r=(grep/$w/,@$k)?-1:$r}$r}
Andrew Savige250print sort{$u=uc$a;$v=uc$b;@x=$u=~/\d+|\D+/g;@y=$v=~/\d+|\D+/g;return$u cmp$v if@x<2||@y<2or$x[0]=~/\d/^$y[0]=~/\d/;for(0..(@x<@y?@x:@y)){$c=$x[$_];$d=$y[$_];$i=length$c;$j=length$d;return$i<=>$j if$c=~/\d/&&$i!=$j;return$c cmp$d if$c ne$d}@x<=>@y}<>
Autrijus Tang117print+sort{my@z;($;=$a)=~s/\d+/push@z,$&;1/eg;$_=$b;s/\d+/1-(length($*=shift@z)<=>length$&||$*cmp$&)/eg;lc$;cmp+lc}<>
Llasse87print sort{"$a$b"=~/^((.*\D)?)(\d+).*\n\1(\d+)/i&&length$3<=>length$4||lc$a cmp lc$b}<>
Llasse82print sort{"$a$b"=~/^(.*)(\d+).*\n\1(\d+)/i&&length$2<=>length$3||lc$a cmp lc$b}<>
Rick Klement81print sort{($a.$b)=~/(.*)(\d+).*\n\1(\d+)/i&&length$2<=>length$3||uc$a cmp uc$b}<>
Andrew Savige80sub Z{$_=pop;s/\d+/sprintf("%010d",length$&).$&/eg;uc}print sort{Z($a)cmp Z$b}<>
BoB79print+sort{s|\d+|sprintf"%".length("@_")."s",$&|egfor@_=($a,$b);$_[0]cmp$_[1]}<>
Eugene van der Pijll77sub a{$_=lc pop;s#\d+#0 .pack(N,length$&).$&#ge;$_}print sort{a($a)cmp a$b}<>
Marcus Holland-Moritz76print sort{s/\d+/sprintf"%9d$&",length$&/egfor($",$;)=(uc$a,uc$b);$"cmp$;}<>
BoB73print+sort{s|\d+|0 x length("$@").$&|egfor@_=($a,lc$b);lc$_[0]cmp$_[1]}<>
Piers Cawley73print map/\n(.+)/s,sort map{($a=lc)=~s|\d+|0${\pack'N/a*',$&}$&|g;$a.$_}<>
Andrew Savige72sub Z{s/\d+/0 .(':'x length$&).$&/eg;uc}print sort{Z($_=$a)cmp Z$_=$b}<>
Eugene van der Pijll71sub a{$_=lc pop;s#\d+#0 .pack'N/A*',$&#ge;$_}print sort{a($a)cmp a$b}<>
Andrew Savige71sub Z{s/\d+/0 .(A x length$&).$&/eg;uc}print sort{Z($_=$a)cmp Z$_=$b}<>
Suo69print/(.*\n)$/for sort map{($x=lc)=~s#\d+|\n#pack'xN/a*',$&#eg;$x.$_}<>
Ian Phillips69sub t{$_=pop;s/\d+/(1e9+length$&).$&/ge;lc}print sort{t($a)cmp t$b}<>
Autrijus Tang69-p $k=$_;$_=lc;s!|\d+!pack'AN/Z*',0,$&!eg;$;{$_}.=$k}for(@;{sort%;}){
Marcus Holland-Moritz69print sort{s!\d+!pack'AN/A*',0,$&!egfor($",$;)=(uc$a,uc$b);$"cmp$;}<>
Autrijus Tang66-p ($*=lc)=~s!|\d+!pack'AN/A*',0,$&!eg;$;{$*}.=$_}for(@;{sort%;}){
Spiff65sub f{$_=pop;s;\d+;9 x9+$+[0].$&;eg;lc}print+sort{f($a)cmp+f$b}<>
Marcus Holland-Moritz65print sort{s!\d+!pack'AN/A*',0,$&!egfor$"=uc$a,$;=uc$b;$"cmp$;}<>
BoB64sub f{$_=pop;s;\d+;1e9+$+[0].$&;eg;uc}print+sort{f($a)cmp+f$b}<>
Spiff64sub f{$_=pop;s|\d+|9x9+$+[0].$&|eg;lc}print+sort{f($a)cmp+f$b}<>
BoB63sub f{s;\d+;1e9+$+[0].$&;eg;uc}print+sort{f($_=$a)cmp+f$_=$b}<>
BoB62sub f{s;\d+;$^T+$+[0].$&;eg;uc}print+sort{f($_=$a)cmp+f$_=$b}<>
BoB61print sort{s!\d+!1e9+$+[0].$&!egfor$"=uc$a,$;=uc$b;$"cmp$;}<>
BoB60print sort{s!\d+!$^T+$+[0].$&!egfor$"=uc$a,$;=uc$b;$"cmp$;}<>
BoB60-p $k=$_;s!|\d+!1e9+$+[0].$&!eg;$;{+uc}.=$k}for(@;{sort%;}){
BoB59-p $k=$_;s!|\d+!$^T+$+[0].$&!eg;$;{+uc}.=$k}for(@;{sort%;}){
BoB59-paF s!|\d+!1e9+$+[0].$&!eg;$;{+uc}.="@F\n"}for(@;{sort%;}){
BoB58-paF s!|\d+!$^T+$+[0].$&!eg;$;{+uc}.="@F\n"}for(@;{sort%;}){
 
Assignment 2: fair shuffle
 
Jonathan E. Paton121-w @a=<>;for(@INC){open F,$_."/pod/perlfaq4.pod"or next;undef$/;$_=<F>;($_)=/(my\$arr.*?\})/s;s'shift'\@a's;eval;print@a} (rejected, doesn't seem to pick up the right code in my perl)
Jonathan E. Paton118@a=<>;for(@INC){open F,$_."/pod/perlfaq4.pod"or next;undef$/;$_=<F>;($_)=/(my\$arr.*?\})/s;s'shift'\@a's;eval;print@a} (rejected, doesn't seem to pick up the right code in my perl)
Jonathan E. Paton33-n $a{$..rand}=$_}{print values%a (rejected)
Autrijus Tang32-n splice@_,rand@_,0,$_}{print@_ (rejected)
Piers Cawley32-p splice@a,rand@a,0,$_}for(@a){ (rejected)
Andrew Savige32%C=map{rand,$_}<>;print values%C (rejected)
Richard Proctor31-n $_{+rand}=$_}{print values%_ (rejected)
BoB30-n $a{+rand}=$_}for(values%a){ (rejected)
BoB30-n $a{$..rand}=$_}for(@a{%a}){ (rejected)
Autrijus Tang28print+sort{int(rand(3))-1}<> (rejected)
BoB28-n $a{+rand}=$_}for(@a{%a}){ (rejected)
Richard Proctor28-n $_{+rand}=$_}{print@_{%_} (rejected)
Yen-Ming Lee27print sort{rand 2>1?-1:1}<> (rejected)
BoB23print+sort{rand(2)-1}<> (rejected)
Gimbo20print sort{rand 2}<> (rejected)
 
J.Robert Suckling46@A=<>;while(@A){print splice @A,int rand @A,1}
Patrick Gaskill44@a=<>;print splice@a,int rand$#a+1,1 while@a
BoB40@f=<>;print splice(@f,rand(@f),1)while@f
Kye Leslie40@a=<>;while(@a){print splice@a,rand@a,1}
Dave Hoover40@a=<>;print splice@a,int rand@a,1while@a
Suo37@x=<>;print splice@x,rand@x,1 while@x
Ian Phillips37@x=<>;print splice @x,rand@x,1while@x
Ion36@a=<>;print splice@a,rand@a,1while@a
Andrew Savige36@a=<>;print splice@a,rand@a,1while@a
Ronald J Kimball36@a=<>;print splice@a,rand@a,1while@a
Ian Phillips36@x=<>;print splice@x,rand@x,1while@x
Dave Hoover36@a=<>;print splice@a,rand@a,1while@a
Autrijus Tang35@_=<>;print+delete$_[rand@_]while@_
Llasse35print splice@a,rand@a,1 for@b=@a=<>
Autrijus Tang34-n splice@_,rand@_+1,0,$_}{print@_
Spiff34print+splice@,,rand@,,1for@==@,=<>
Jonathan E. Paton34print splice@a,rand@a,1for@b=@a=<>
Piers Cawley34-p splice@a,rand@a+1,0,$_}for(@a){
Autrijus Tang34-p splice@F,rand@F+1,0,$_}for(@F){
Suo33print map{splice@x,rand@x,1}@x=<>
Andrew Savige33print map{splice@x,rand@x,1}@x=<>
Spiff33-n splice@,,rand$.,0,$_}print@,;{
Eugene van der Pijll32-p splice@a,rand$.,0,$_}for(@a){
Spiff32-p splice@F,rand$.,0,$_}{print@F
Andrew Savige32-n splice@x,rand$.,0,$_}{print@x
Marcus Holland-Moritz32-n splice@_,rand$.,0,$_}{print@_
Rick Klement32-n splice@a,rand$.,0,$_}{print@a
Autrijus Tang32-p splice@.,rand$.,0,$_}for(@.){
 
Assignment 3: select 2
 
Jonathan E. Paton40@a=<>;splice@a,rand@a,1while@a>2;print@a (rejected)
Autrijus Tang37-n splice@_,rand@_,0,$_}{print@_[0,1] (rejected)
Piers Cawley37-p splice@a,rand@a,0,$_}for(@a[0,1]){ (rejected)
Autrijus Tang37-nla0 print+splice@F,rand@F,1,for$,,1 (rejected)
Yen-Ming Lee37print((sort{rand 2>1?-1:1}(<>))[0,1]) (rejected)
Jonathan E. Paton34-n $a{$..rand}=$_}{print+(%a)[1,3] (rejected)
BoB33-p $a{$..rand}=$_}for((%a)[1,3]){ (rejected)
Richard Proctor32-n $_{+rand}=$_}{print+(%_)[1,3] (rejected)
BoB31-p $a{+rand}=$_}for((%a)[1,3]){ (rejected)
 
Kye Leslie47@a=<>;$a=2;while($a--){print splice@a,rand@a,1}
J.Robert Suckling45@A=<>;for(1,2){print splice @A,int rand @A,1}
Patrick Gaskill44@a=<>;print splice@a,int rand$#a+1,1 for+1,2
Eugene van der Pijll41print splice(@a,rand(@a=<>),1),$a[rand@a]
Dave Hoover41@a=<>;map{print splice@a,int rand@a,1}0,0
Piers Cawley39-p splice@a,rand@a+1,0,$_}for(@a[0,1]){
Andrew Savige38@x=<>;eval'print splice@x,rand@x,1;'x2
Autrijus Tang37@_=<>;map{print+splice@_,rand@_,1}1,2
Suo37@x=<>;print splice@x,rand@x,1 for 1,1
Llasse37@a=<>;print splice@a,rand@a,1 for 1,2
Andrew Savige37@a=<>;print splice@a,rand@a,1for 1..2
Ian Phillips37@x=<>;print splice@x,rand@x,1for 1..2
Autrijus Tang37@F=<>;print+splice@F,rand@F,1,for$,,1
Rick Klement37-n splice@a,rand$.,0,$_}{print@a[0,1]
Dave Hoover37@a=<>;map{print splice@a,rand@a,1}1,1
Ronald J Kimball36@a=<>;print splice@a,rand@a,1for 1,2
Ion36@_=<>;print+splice@_,rand@_,1for+1,2
Suo36print splice@x,rand@x,1 for[@x=<>],1
Eugene van der Pijll36@a=<>;print splice@a,rand@a,1for a,b
Ian Phillips36@x=<>;print splice@x,rand@x,1for 1,2
Andrew Savige36@a=<>;print splice@a,rand@a,1for 1,2
Marcus Holland-Moritz36@_=<>;print splice@_,rand@_,1for 0,0
Spiff35print+splice@,,rand@,,1for[@,=<>],f
Eugene van der Pijll35-p splice@a,rand$.,0,$_}{($_,$\)=@a
Andrew Savige35-p splice@x,rand$.,0,$_}{($_,$\)=@x

Read more about perl golf

Ton Hospel