Hi, You may recall a few weeks ago I promised to summarise the results of the brief coding problem I put forward. Well its better late than never... For those who have forgotten, the question was to solve the following with the smallest number of characters. > The weekly circular contained a little puzzle. Find a 4 digit number ABCD > and a five digit number EFGHI such that: > ABCD / EFGHI = 1 / 66 > such that numbers 1 through 9 are all represented as digits in ABCD and > EFGHI. > Amazingly enough the best solution so far takes only 44 chars to get the value for ABCD, or 63 chars if you require the full formatted output. [Note: In keeping with the netiquette rules of this list I have not named names. My apologies to those who contributed and wanted their name up in pixels, but I'd better keep to the rules. Contributors, please post your comments!] < Spoiler Gap> | | \ / | | \ / | | \ / | | \ / #Sol1 This was my original 74 char solution I had in mind when I # posted the question, since then there have been many improvements. # for(;123456789-join("",sort split//,++$a.($b=$a*66));){};print"$a/$b=1/66" #Sol2 Another suggested derivation, but a bit too long at 78 chars # L:while(1){$a++;for(1..9){($a.($b=$a*66))=~/$_/||next L}print"$a/$b=1/66";last} #Sol3 With a bit of maths and applying a more tidy 1while construction # the join/split method can be reduced to 69 chars # 1while((join"",sort split//,++$a.($b=$a*66))%10821);print"$a/$b=1/66" #Sol4 This was blown out of the water by the use of RE's and map # down to only 49 chars. Note, this only prints the ABCD part # of the solution, but can find multiple solutions (Eg 44) # map{$p=66*$_;($_.$p)!~/0|(.).*\1/&&print}1E3..1E4 #Sol5 With slight tinkering Sol4 can be reduced to 44 chars # or into a pretty printed result with only 63 chars # map{print if($_.66*$_)!~/0|(.).*\1/}1E3..1E4 for($a=1E3;(++$a.($b=66*$a))=~/0|(.).*\1/;){};print"$a/$b=1/66" So that's where its at now. Anyone have any different ideas on how to improve this. Cheers, Alistair -------------------------------------------------------------------- Alistair McGlinchy, alistair.mcglinchy@marks-and-spencer.com Sizing and Performance, Central IT ext. 5012, ph +44 0 171-268-5012 Marks and Spencer (Stockley Park) fx +44 0 171-268-5721 1SW, 3 Longwalk Rd, Stockley Park, Uxbridge UB11 1AW, United Kingdom _____________________________________________________________________________________________________ Registered Office: Marks and Spencer plc Michael House, Baker Street, London, WIA IDN Registered No. 214436 in England and Wales. Telephone 0171-935-4422 Facsimile 0171-487-2670 www.marks-and-spencer.com This e-mail is Confidential. If you received it by mistake, please let us know and then delete it from your system; you should not copy, disclose, or distribute its contents to anyone nor act in reliance on this e-mail, as this is prohibited and may be unlawful. _____________________________________________________________________________________________________ ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe