-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSumSquare.py
More file actions
56 lines (44 loc) · 1.49 KB
/
SumSquare.py
File metadata and controls
56 lines (44 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
__author__ = 'Michael Byrd'
# Laptop
import time, random, math
from Graph import *
from MathFunctions import *
import csv
import ast
from SequenceFunctions import *
legalPaths = {}
# for N in range(15, 25):
# b = time.time()
# g = Graph(sumSquareList(1, N))
# legalPaths[N] = {}
# for i in range(1, N + 1):
# legalPaths[N][i] = []
# for j in range(i, N + 1):
# paths = g.find_all_paths(i, j)
# for item in paths:
# if len(item) == N:
# legalPaths[N][i].append(item)
# e = time.time()
# print(N, e-b)
# writeList = []
# for key0 in legalPaths:
# for key1 in legalPaths[key0]:
# for item in legalPaths[key0][key1]:
# # writeList.append(["N:", len(item), "\t (", item[0], ", ", item[-1], ") \t", item])
# writeList.append([len(item), item[0], item[-1], item])
# # print(len(item), "\t", item[0], "\t", item[-1], "\t", item)
#
# print(writeList[3])
#
# with open("output.csv", "w", newline="") as f:
# writer = csv.writer(f)
# writer.writerows(writeList)
## GitHub
# for N in range(1, 31):
# g = Graph(SquareSumDiffList(1, N))
# for i in range(1, N + 1):
# for j in range(i, N + 1):
# if len(g.findLongestPath(i, j)) == N:
# print("N", N, "I", i, "J", j, g.findLongestPath(i, j), len(g.findLongestPath(i, j)))
# print(len(Graph(sumSquareList(1, 13)).edges()))
print(Graph(sumSquareList(1, 32)).findLongestPath())