Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public long factorial(int number) {
- long result = 1;
- for (int factor = 2; factor <= number; factor++) {
- result *= factor;
- }
- return result;
- }
- public String[] unRank(String set, int n)
- {
- String res[] = new String[set.length()];
- while (set.length() > 0)
- {
- int setSize = (int) factorial(set.length()-1);
- int index = n/setSize;
- res+=set.charAt(index);
- set = index > 0 ? set.substring(0, index) : "" +
- (index < set.length()-1) != null ? set.substring(index+1) : "";
- n = n % setSize;
- }
- return res;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement