Advertisement
defango

REEE

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