Advertisement
Guest User

Untitled

a guest
Nov 17th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. public class HelloWorld{
  2.  
  3. public static final String chars = "`~1!2@3#4$5%6^7&8*9(0)-_=+qwertyuiop[{]}asdfghjkl;:zxcvbnm,<.>/?";
  4. public static final int length = chars.length();
  5. public static int limit = 3;
  6.  
  7. public static void main(String []args){
  8. double max = Math.pow(chars.length(), limit);
  9.  
  10. //for (int i = 0; i < (int) max; i++) {
  11. //System.out.println((i + 1) + ": " + find(i));
  12. //}
  13. System.out.println("Test: " + find(4096));
  14. }
  15.  
  16. public static String find(int i) {
  17. String base = String.valueOf(i);
  18. String result = "";
  19.  
  20. if (i < length) {
  21. result += chars.substring(i, i + 1);
  22. } else {
  23. int divide = i / length;
  24. int multiply = divide * length;
  25.  
  26. if (divide >= length) {
  27. return "NULL";
  28. }
  29. result += chars.substring(divide, divide + 1);
  30.  
  31. i -= multiply;
  32. result += chars.substring(i, i + 1);
  33. }
  34. return result;
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement