Results 1 to 7 of 7
 11302008, 10:59 PM #1Member
 Join Date
 Nov 2008
 Posts
 67
 Rep Power
 0

At your current level, I'd bet you'd be able to solve this without our help. Why not first give it a go? Also, myself, I'd use characters or String representations of the numbers since we're not really treating these things as numbers.
 12012008, 05:50 AM #3
 Join Date
 Jul 2007
 Location
 Colombo, Sri Lanka
 Posts
 11,370
 Blog Entries
 1
 Rep Power
 21
 12012008, 11:45 PM #4Member
 Join Date
 Nov 2008
 Posts
 67
 Rep Power
 0
I found the following code (courtesy of Permutations.java). For the particular problem I'm trying to do, I need to find the 1000000th permutation. How would I modify this code to do that?
Java Code:// print N! permutation of the characters of the string s (in order) public static void perm1(String s) { perm1("", s); } private static void perm1(String prefix, String s) { int N = s.length(); if (N == 0) System.out.println(prefix); else { for (int i = 0; i < N; i++) perm1(prefix + s.charAt(i), s.substring(0, i) + s.substring(i+1, N)); } }
 12022008, 01:35 AM #5
hhhmmm...
 Do you know what that piece of code does?
 Do you know what the "prefix" and "s" variables are? What they represent?
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
 12022008, 04:00 AM #6Senior Member
 Join Date
 Sep 2008
 Posts
 564
 Rep Power
 8
I don't understand what the 1 millionth (or nth) permutation means. There is no order to permutations.
 12022008, 04:59 AM #7Member
 Join Date
 Nov 2008
 Posts
 67
 Rep Power
 0
Similar Threads

how to extract the number of the image which looks like a number
By Crest.Boy in forum Java ServletReplies: 1Last Post: 11032008, 03:38 PM 
given number of points(cordinates) , find max points lie on the same line ?
By Hayzam in forum New To JavaReplies: 2Last Post: 08242008, 12:30 AM 
how to right a program that find kth number in two sorted array?
By fireball2008 in forum New To JavaReplies: 8Last Post: 04222008, 03:21 AM 
Find nth root of a number
By perito in forum New To JavaReplies: 1Last Post: 03032008, 07:51 AM 
PLEASE!!!help me to find mistake
By sasha20 in forum New To JavaReplies: 1Last Post: 01112008, 11:50 AM
Bookmarks