Another golf already? I can't take it! Btw, I think my last showing was pretty respectable considering we had a baby the Sunday the contest started!
Anyway, why did noone post their solutions? $_=z.1x($y=pop);$y-=s/1/;/while/z.1|\b(..+)\1+\b/;print"[EMAIL PROTECTED] " 1. $y=pop (number to find, which we'll call G) 2. $_=z.1x Create a string with that many '1's plus a z at the beginning. (I'll explain the z later.) 3. $y-=s/1/;/ Each time through the loop, replace the next (remaining) 1 with a ; and subtract one from $y. So if you go through the loop n times, $y will be G - n. And you'll always have a string of a followed by n semicolons followed by $y 1's. 4. while/z.1|\b(..+)\1+\b/ 4a. \b(..+)\1+\b (..+)\1+ is Abigail's famous prime number finder. Basically it finds that you can divide the string evenly into smaller pieces of length at least 2, i.e., that the length of the string is composite. I've replaced Abigail's ^ and $ with \b \b. I sort of accidentally realized that this will find whether one substring OR the other is composite. If either is composite, we haven't found the primes yet. I learned something about \b in this contest: \b finds boundaries between \w and \W, but ^ and $ count as \W! That is, \b will not match anywhere in a string like ";;;;", even though it matches the beginning and end of the string "1111". I had to put the z at the front of the string so that \b would match the beginning of the semicolons. 4b. z.1| The ugly part: a lone semicolon doesn't match the above regexp, so the second time you test the while, if G-1 is a prime, it'll exit. People who used $^F (automatically equal to two!) got around this problem, but it didn't help my solution. 5. print"[EMAIL PROTECTED] " I'm glad I asked the mailing list about "@-" after the last contest! It prints the last place that was matched (but doesn't work in 5.6), so we're printing the new $y, which is G-n, and @-, which is the last place we replaced a '1' which happens to be at position n by dumb luck. (If I didn't have the z at the beginning of the string, I would've printed @+ instead.). Followed by a literal \n. By the way, why isn't terje.perlgolf.org working? Also, I didn't get the email announcement, which I think I did get for the contest before this one. -Amir __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com