Advertisement
Guest User

Untitled

a guest
Apr 19th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. public long factorial(int number) {
  2. long result = 1;
  3.  
  4. for (int factor = 2; factor <= number; factor++) {
  5. result *= factor;
  6. }
  7.  
  8. return result;
  9. }
  10. public String[] unRank(String set, int n)
  11. {
  12. String res[] = new String[set.length()];
  13. while (set.length() > 0)
  14. {
  15. int setSize = (int) factorial(set.length()-1);
  16. int index = n/setSize;
  17. res+=set.charAt(index);
  18. set = index > 0 ? set.substring(0, index) : "" +
  19. (index < set.length()-1) != null ? set.substring(index+1) : "";
  20.  
  21. n = n % setSize;
  22. }
  23. return res;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement