Page 2 of 2 FirstFirst 12
Results 21 to 23 of 23

Thread: I Failed

  1. #21
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    Quote Originally Posted by al_Marshy_1981 View Post
    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 04:57 AM.

  2. #22
    StanO is offline Member
    Join Date
    Nov 2010
    Posts
    4
    Rep Power
    0

    Default

    Quote Originally Posted by JosAH View Post
    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. #23
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    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 FirstFirst 12

Similar Threads

  1. JVM creation failed
    By RogerP in forum NetBeans
    Replies: 12
    Last Post: 10-08-2011, 09:33 PM
  2. failed to connect to DB
    By danghieu in forum New To Java
    Replies: 16
    Last Post: 05-25-2010, 11:27 AM
  3. my Quicksort attempt has failed
    By Jeremy8 in forum New To Java
    Replies: 4
    Last Post: 11-16-2009, 02:56 AM
  4. Failed in reading xml
    By gayathri_g in forum New To Java
    Replies: 0
    Last Post: 08-27-2009, 02:07 PM
  5. failed to connect to remote vm
    By plummer in forum Eclipse
    Replies: 1
    Last Post: 05-08-2009, 08:11 AM

Posting Permissions

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