Guest User

Untitled

a guest
Dec 6th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. //This is unfinished. I'm not entirely sure how HashMaps work. I'm trying to call some methods on the objects stored by calling get() with the corresponding Integer, but it calls the methods on the Integer instead. It's nearly 3am and nobody else seems to be using this anyway so here you go.
  2.  
  3. import java.util.ArrayList;
  4. import java.util.HashMap;
  5. import java.util.Map;
  6. import java.io.File;
  7. import java.io.FileNotFoundException;
  8. import java.io.PrintWriter;
  9.  
  10. public class TheEnd{
  11.  
  12. public static String path = ""; //FILE PATH GOES HERE
  13. public static HashMap<HashMap<ArrayList, Integer>, Integer> theend
  14. = new HashMap<HashMap<ArrayList, Integer>, Integer>();
  15.  
  16. public static void main(String[] args){
  17. CreateTheEnd(512, 0, 0, 64, 64);
  18. Output(256, -64, 0, 64, 64, 12);
  19. }
  20.  
  21. public static void CreateTheEnd(int i_max, int x_min, int y_min, int x_max,
  22. int y_max){
  23. String text = "";
  24. for(int i = 0; i < i_max; i++){
  25. for(int j = 0; j < i; j++){
  26. int a = i - j;
  27. int b = i + j;
  28. int c = a * b;
  29. boolean odd = (c % 2 == 1);
  30. int d = (int) Math.sqrt(c);
  31. int e = c - (d * d);
  32. int f = e - ((2 * d) + 1);
  33. int n = i - d;
  34. int x = d - a;
  35. if(theend.containsValue(e) == false){
  36. theend.put(new HashMap<ArrayList, Integer>(), e);
  37. }
  38. if(theend.get(e).containsValue(n) == false){
  39. theend.get(e).put(new ArrayList(), n);
  40.  
  41. if(odd){
  42. //bmp.SetPixel(e, n, Color.White);
  43. }
  44. }
  45. if(theend.containsValue(f) == false){
  46. theend.put(new HashMap<ArrayList, Integer>(), f);
  47. }
  48. if(theend.get(f).containsValue(n - 1) == false){
  49. theend.get(f).put(new ArrayList(), (n-1));
  50. }
  51. theend.get(e).get(n).add(text);
  52. text = ("{" + f + "}:{" + (n-1) + "}:{" + (d+1) + "}:{" + (x+1)
  53. + "}:{" + a + "}:{" + b + "}");
  54. theend.get(f).get(n-1).add(text);
  55. }
  56. }
  57. }
  58.  
  59. public static void Output(int i_max, int x_min, int y_min, int x_max,
  60. int y_max, int set_size) throws
  61. FileNotFoundException{
  62. PrintWriter pw = new PrintWriter(new File("output2.csv"));
  63. StringBuilder sb = new StringBuilder();
  64. for(int y = 0; y < y_max; y++){
  65. for(int z = 0; z < set_size; z++){
  66. for(int x = x_min; x < x_max; x++){
  67. if(theend.containsValue(x) && theend.get(x).containsValue(y) &&
  68. theend.get(x).get(y).size() > z){
  69. sb.append(theend.get(x).get(y).get(z));
  70. } else {
  71. sb.append(",");
  72. }
  73. }
  74. sb.append("\n");
  75. }
  76. }
  77. pw.write(sb.toString());
  78. pw.close();
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment