[golf] Tangled Tale Results
Brad Greenlee <[email protected]>
| Newsgroups | gmane.comp.lang.perl.fun |
|---|---|
| Message-ID | <[email protected]> |
Finally, the [possibly] fun part for you non-golfers. I've included the
solutions below, and also attached them, since (a) mailers will surely
chop things up and confuse things, and (b) Tobias' solution includes
unprintable characters.
First, the correct output:
1 8 5 11 4 9 14 12 2 13 7 15 10 6 3 16
1 12 2 8 5 13 7 11 4 15 10 9 14 6 3 16
(in either order)
1. Terje Kristensen (137)
#!perl -l
sub r{/Q/&@s>15?print map{1+hex,$"}@s:map{"@s"=~$_
or@s=(@s,$_),r($_=substr"7B7C0F8EAC28AE4BDE583C1F675B9AQ",2*hex,2),pop@s}/./g}r$_=0
2. Georg Moritz (150)
map{push(@x,$x+1)while(!$x{$x=hex
substr("7b7c0f8eac28ae4bde583c1f675b9a",$x*2+vec(pack(S,$_),$x,1),1)}++&&$x);print"1
@x
"if@x>14;undef*x}(0..2**15)
4. (tie) Tobias Gödderz (157)
sub f{my$b=$_[$#_];$b+@_==32&&print"@_
";(grep{$_==$b}@_)-1||f(@_,$a[$b-1][$_])for 0..1}$,="
";push@a,[$_&15,($_>>4)+1]for unpack"C*","¸ÃñéÃëµîÃòw¶ª";f(1)
Brad Greenlee (157)
sub f{my($n,$s)=@_;++$n+@t>30?print"@t
$n\n":$s{$n}?'':do{$s{$t[@t]=$n}=1;for(1..2){f(vec('1516*92846,248.578/2-6+901/534',$n*2-$_,8)-42,$s)}$s{pop@t}=0}};f
Congratulations, Terje!
Again, sorry for the golf interruption, FWPers....
Cheers,
-b
tobias.pl
(application/x-perl, 178 B)
#!perl
sub f{my$b=$_[$#_];$b+@_==32&&print"@_
";(grep{$_==$b}@_)-1||f(@_,$a[$b-1][$_])for 0..1}$,=" ";push@a,[$_&15,($_>>4)+1]for unpack"C*","¸ÈñéËëµîÄòw¶ª";f(1)
brad.pl
(application/x-perl, 164 B)
#!perl
sub f{my($n,$s)=@_;++$n+@t>30?print"@t $n\n":$s{$n}?'':do{$s{$t[@t]=$n}=1;for(1..2){f(vec('1516*92846,248.578/2-6+901/534',$n*2-$_,8)-42,$s)}$s{pop@t}=0}};f
georg.pl
(application/x-perl, 157 B)
#!perl
map{push(@x,$x+1)while(!$x{$x=hex substr("7b7c0f8eac28ae4bde583c1f675b9a",$x*2+vec(pack(S,$_),$x,1),1)}++&&$x);print"1 @x
"if@x>14;undef*x}(0..2**15)
terje.pl
(application/x-perl, 145 B)
#!perl -l
sub r{/Q/&@s>15?print map{1+hex,$"}@s:map{"@s"=~$_ or@s=(@s,$_),r($_=substr"7B7C0F8EAC28AE4BDE583C1F675B9AQ",2*hex,2),pop@s}/./g}r$_=0