in reply to a couple of rounds of golf for the weekend
My solution for part 1 (209 chars, including 2 newlines):
@t=map eval"sub{\$n=~tr/1234/$_/;\$n}",((1243,1432)x2,1243,4321)x4;map +{$n= "1234$_";map&$_,@t}map{$_,join"",(split/(....)/)[1,5,3]}341221434321, 341223414123,342121434312,431221433421,432121433412,432124133142
Using the list built in part 1, my solution for part 2 (358 chars, including 4 newlines):
sub p{my($c,$i)=@_;$i==16?$c?():"":(map("0$_",p($c,$i+1)),map"7$_",p($ +c-1,$i+1) )}@t=map eval"sub{\$n=~tr/1234/$_/;\$n}",((1243,1432)x2,1243,4321)x4;@ +f=map{$n= "1234$_";map&$_,@t}map{$_,join"",(split/(....)/)[1,5,3]}341221434321, 341223414123,342121434312,431221433421,432121433412,432124133142;$_=po +p;for$m( p($_)){++$s{$m&$_}for@f}print 0+grep$_<2,values%s
Hugo
|
|---|