Advertisement
Guest User

Untitled

a guest
Dec 8th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. using System;
  2.  
  3. using System.Collections.Generic;
  4. using System.IO;
  5.  
  6. namespace IntegerFactorisation
  7. {
  8. public class TheEnd
  9. {
  10. public static string path = "";//PUT YOUR FILE PATH HERE
  11. public static Dictionary<int, Dictionary<int, List<string>>> theend = new Dictionary<int, Dictionary<int, List<string>>>();
  12.  
  13.  
  14. public static void CreateTheEnd(int i_max = 512, int x_min = 0, int y_min = 0, int x_max = 64, int y_max = 64)
  15. {
  16. for (int i = 0; i < i_max; i++)
  17. {
  18. for (int j = 0; j < i; j++)
  19. {
  20. int a = i - j;
  21. int b = i + j;
  22. int c = a * b;
  23. bool odd = c % 2 == 1;
  24. int d = (int)Math.Sqrt(c);
  25. int e = c - (d * d);
  26. int f = e - ((2 * d) + 1);
  27. int n = i - d;
  28. int x = d - a;
  29. if (!theend.ContainsKey(e)) theend[e] = new Dictionary<int, List<string>>();
  30. if (!theend[e].ContainsKey(n))
  31. {
  32. theend[e][n] = new List<string>();
  33.  
  34. }
  35. if (!theend.ContainsKey(f)) theend[f] = new Dictionary<int, List<string>>();
  36. if (!theend[f].ContainsKey(n - 1)) theend[f][n - 1] = new List<string>();
  37. string text = "{" + string.Format("{0}:{1}:{2}:{3}:{4}:{5}", e, n, d, x, a, b) + "}";
  38. theend[e][n].Add(text);
  39. text = "{" + string.Format("{0}:{1}:{2}:{3}:{4}:{5}", f, n - 1, d + 1, x + 1, a, b) + "}";
  40. theend[f][n - 1].Add(text);
  41. }
  42. }
  43. }
  44. public static void Output(int i_max = 256, int x_min = -64, int y_min = 0, int x_max = 64, int y_max = 64, int set_size = 12)
  45. {
  46. TextWriter tw = File.CreateText(path + "output.csv");
  47. for (int y = 0; y < y_max; y++)
  48. {
  49. for (int z = 0; z < set_size; z++)
  50. {
  51. for (int x = x_min; x < x_max; x++)
  52. {
  53. if (theend.ContainsKey(x) && theend[x].ContainsKey(y) && theend[x][y].Count > z)
  54. {
  55. tw.Write(theend[x][y][z] + ",");
  56. }
  57. else
  58. {
  59. tw.Write(",");
  60. }
  61. }
  62. tw.WriteLine("");
  63. }
  64. }
  65. tw.Close();
  66. }
  67. }
  68. }
  69.  
  70. namespace BringTheEnd
  71. {
  72. class Program
  73. {
  74. static void Main()
  75. {
  76. IntegerFactorisation.TheEnd.CreateTheEnd();
  77. }
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement