1. Moderator
Join Date
Feb 2009
Location
New Zealand
Posts
4,717
Rep Power
16
Originally Posted by al_Marshy_1981
that algorithm was beautiful :D

I agree. There's a nice article in Wikipedia about factoradics and the combinatorial number system. (With colourful pictures and graphs and references to 19th century work in the area.)
Last edited by pbrockway2; 11-20-2010 at 05:57 AM.

2. Member
Join Date
Nov 2010
Posts
4
Rep Power
0
Originally Posted by JosAH
Your algorithm is identical to mine; my version uses a loop while your version unraveled the loop.
Yes it is! You recognized the arithmetic and factorial constants and correctly concluded “identical” algorithms.

Now, fold the constants:

static List<Integer> l = new ArrayList<Integer>(Arrays.asList(new Integer[] {1, 2, 3, 4, 5, 6, 7, 8, 9}));
static void a(int i) { System.out.print(l.remove(i)); }
public static void main(String[] args) { a(2);a(3);a(5);a(5);a(1);a(2);a(1);a(1);a(0); }

Not only is it unrecognizable it looks strikingly close to just printing the answer. Yet these solutions are “identical” !

Would the magazine accept this "solution"?

I can only conclude that the intent of the original problem statement was to generate the first 100,000 permutations. Something neither of us did.

Regards,
StanO

3. Moderator
Join Date
Feb 2009
Location
New Zealand
Posts
4,717
Rep Power
16
There are a large number of 9 digit integers in the range 123456789 to 987654321 where each digit only appears once. What is the 100,000th number in this sequence?

My read of this would be to take the "100,000" as relatively unimportant. A solution would embody an approach: with trivial changes it should produce the n-th largest number for any n.

This is very different from actually computing the n-th largest for every n (up to 100000 or whatever). That would be an approach, but a poor one in terms of speed.

Page 2 of 2 First 12

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•