Re: Hamming minigolf post mortem

[email protected] (Terje Kristensen)
Newsgroups perl.golf
Message-ID <[email protected]>
Since i had a bit different solution from the rest of you, i thought that i 
might follow mtve's good example and write up how it works.

printf"%s
"x4096,sort{$a<=>$b}map/(..)(..)/*2**$1*3**$2*5**$',$x6..$~

basicly i do a 000000 to 999999 loop, and pick out the first middle and 
last 2 digits. the 2**$1*3**$2*5**$' gives me the numbers that contains 
just 2, 3 and 5 as elements, 0 to 99 times each. it's a big overkill since 
it gives me much more than i need, but it's short :)

the printf part is simply shorter than the print+()[0..4095] that i had 
first. the "%s\n"x4096 gives me a string that have 4096 times "%s\n", and 
when i send my list into it, it only prints the first 4096 numbers, 
disregarding the rest. i would have used %d, but that only handles numbers 
up to 2**32, and %0.f is too long.

the reason for using $^C is a long one, but i wanted to use $~ as the end 
value in my map since it's 6 chars it fit perfectly but this doesnt work.
perl -le 'print for 0 x6..$~'. this works tho perl -le 'print for 0 x6..~$~'

while testing all the possible variables i changed my testing to use
"print ${xx}x6..$~" and suddenly found something that worked .. it happened 
to be $^C, and i thought it was a magic variable. maybe i was tired :)

the fact that "print 0 x6..$~" works didnt even cross my mind since i knew 
that "print for 0 x6..$~" didnt work. can anyone explain this to me ? :)

Terje K
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.