Python solution Mike 31st July, 2009 06:42 (UTC)

2783915604 calculated in 0.000388 seconds on my MBP

I can't paste either the output or the code as this wiki screws it up, so see http://dpaste.com/hold/73577/ for my solution (a python class).

It works by repeatedly dividing the remaining number of combinations left from the initial 1000000, by the factorial of an integer decreasing from 9 to 0. The integer part of these divisions give an index into a list of digits that are popped off, so we always get a digit we haven't used.

PS. I wrote this on my iPhone using MobileTerminal on the way to the BeerCamp. (iPhone solution took 0.0025 s). All you can eat and jugs of beer for 89 baht at a japanese restaurant… we ended up drinking 'real' sangria back at Thomas's place where BeerCamp all started. Great fun!

Python solution Kirit Sælensminde 31st July, 2009 06:50 (UTC)
Mike said

2783915604 calculated in 0.000388 seconds on my MBP

So close, but not quite right. I think you're off by one permutation.


To join in the discussion you should register or log in
Python solution Mike 31st July, 2009 07:55 (UTC)

2783915460

Generalised the solution a bit more (it can now handle bigger sets of digits):

http://dpaste.com/hold/73584/

Python solution Mike 1st August, 2009 10:41 (UTC)

Thomas' solution:

ima, zlr = 123456789, 1
while zlr < 10**6:
    ima += 1
    rup = ima
    if rup < 10**9: rup *= 10
    if len(set(str(rup)))== 10: zlr += 1
print ima

For next week's beercamp puzzle: someone please figure out what those variables actually stand for…

Python solution Mike 1st August, 2009 10:41 (UTC)

Thomas' solution:

ima, zlr = 123456789, 1
while zlr < 10**6:
    ima += 1
    rup = ima
    if rup < 10**9: rup *= 10
    if len(set(str(rup)))== 10: zlr += 1
print ima

For next week's beercamp puzzle: someone please figure out what those variables actually stand for…

Python solution Mike 1st August, 2009 10:43 (UTC)

Thomas' solution:

ima, zlr = 123456789, 1
while zlr < 10**6:
    ima += 1
    rup = ima
    if rup < 10**9: rup *= 10
    if len(set(str(rup)))== 10: zlr += 1
print ima

For next week's beercamp puzzle: someone please figure out what those variables actually stand for…

Python solution Mike 1st August, 2009 10:43 (UTC)

Thomas' solution:

ima, zlr = 123456789, 1
while zlr < 10**6:
    ima += 1
    rup = ima
    if rup < 10**9: rup *= 10
    if len(set(str(rup)))== 10: zlr += 1
print ima

For next week's beercamp puzzle: someone please figure out what those variables actually stand for…

Python solution Mike 1st August, 2009 10:46 (UTC)
Oops, the www.kirit.com server kept giving me an odd error that looked like I had failed to post so I kept trying.