Last active
September 6, 2019 05:17
-
-
Save JupiterDude/ceb5fc1fcfd469d50b637bd4bd138a28 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inputs = [ | |
["A", 2, "B"], | |
["B", 2, "C"], | |
["C", 2, "D"], | |
["D", 2, "E"], | |
["E", 2, "F"], | |
["F", 2, "G"], | |
["G", 2, "H"], | |
["H", 2, "I"], | |
["I", 2, "J"], | |
["J", 2, "K"], | |
["K", 2, "L"], | |
["L", 2, "M"], | |
["M", 2, "N"], | |
["N", 2, "O"], | |
["O", 2, "P"], | |
["P", 2, "Q"], | |
["Q", 2, "R"], | |
["X", 2, "Y"] ] | |
all = inputs.copy() | |
count = 0 | |
for z in range(1, 10000): | |
count += 1 | |
new_all = all.copy() | |
found = False | |
for a in all: | |
for b in all: | |
if a[0] == b[2] and a[2] != b[0]: | |
new_item = [b[0], a[1] * b[1], a[2]] | |
if not new_item in new_all: | |
found = True | |
new_all.append(new_item) | |
if not found: | |
break | |
all = new_all.copy() | |
print("That took " + str(count) + " outer loops.") | |
new_all = [] | |
for x in all: | |
new_all.append(x) | |
y = x.copy() | |
y.reverse() | |
y[1] = 1 / y[1] | |
new_all.append(y) | |
all = sorted(new_all, key=lambda x: (x[0], x[2])) | |
for x in all: | |
print(x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment