Guest User

Original VQC code

a guest
Dec 16th, 2017
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.93 KB | None | 0 0
  1. To create the grid, attached is a c# file.
  2. There is a method that constructs the grid.
  3. There is an output method.
  4. Please specify a path to save output to.
  5. Next, we will look at some properties of the grid and also examine the all important first row.
  6. The code is below. Cut and pasted.
  7. //
  8. using System;
  9. using System.Collections.Generic;
  10. using System.IO;
  11. namespace IntegerFactorisation
  12. {
  13.     public class TheEnd
  14.     {
  15.         public static string path = "";//PUT YOUR FILE PATH HERE
  16.         public static Dictionary<int, Dictionary<int, List<string>>> theend = new Dictionary<int, Dictionary<int, List<string>>>();
  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. }
Add Comment
Please, Sign In to add comment