From f6ff66ea2da1f30303f17a2dac341411fb325881 Mon Sep 17 00:00:00 2001 From: blenovo Date: Sat, 16 Aug 2025 00:38:26 +0200 Subject: final puzzle and little cleanup for 2018 --- 2018/aoc2018-d07-1.py | 116 -------------------------------------------------- 1 file changed, 116 deletions(-) delete mode 100755 2018/aoc2018-d07-1.py (limited to '2018/aoc2018-d07-1.py') diff --git a/2018/aoc2018-d07-1.py b/2018/aoc2018-d07-1.py deleted file mode 100755 index b734e18..0000000 --- a/2018/aoc2018-d07-1.py +++ /dev/null @@ -1,116 +0,0 @@ -#class step: -# def __init__(self, name, unlocks): -# self.name = name; -# self.unlocks = unlocks; - - -def TransInstr (instruction): - return [instruction[5], instruction[36]]; - - -myinput = {}; - -currentfilename = "input.txt"; -#currentfilename = "testinput.txt"; - -f = open(currentfilename, 'r'); - -#list1 = []; -#list2 = {}; -list2 = set(); - -for line in f: - nowinstr = TransInstr(line); - #myinput[nowinstr[1]].append(nowinstr[0]); - list2.add(nowinstr[0]); - -#''' - try: - myinput[nowinstr[1]].append(nowinstr[0]); - #myinput[nowinstr[1]] = nowinstr[0]; - except: - myinput[nowinstr[1]] = []; - myinput[nowinstr[1]].append(nowinstr[0]); -#''' - -print(myinput.keys()); -print("##############"); -print(list2); -print("##############"); - -pr1 = list(myinput.keys()); -pr1.sort(); -pr2 = list(list2); -pr2.sort(); -print(pr1); -print(pr2); -print("##############"); - -print("##############"); -print("finding the first step"); - -CurrentStep = ''; - -AvailableSteps = []; -#AvailableSteps.append(CurrentStep); - -for l in list2: - IsUnique = True; - for k in myinput.keys(): - #print("L ", l, "\tK ",k, "\t",l == k); - if (l == k): - IsUnique = False; - break; - if IsUnique: - #CurrentStep = l; - #break; - AvailableSteps.append(l); - -print("Unique values are ", AvailableSteps); - -print("##############"); -print(myinput); -print("##############"); -part1 = ""; #CurrentStep; - -#list1 = myinput.keys(); -#list1.append(CurrentStep); -#print(list1); - - -while (len(AvailableSteps) != 0): - #input(); - AvailableSteps.sort(); - CurrentStep = AvailableSteps[0]; - part1 += CurrentStep; - print("now ", CurrentStep); - for step in myinput: - #x = myinput[step].index(CurrentStep); - #print(x, "\t",myinput[step]); - #myinput[step].pop(0); - #print(x, "\t",myinput[step]); - try: - #print("try worked"); - myinput[step].pop(myinput[step].index(CurrentStep)); - except: - #print("skip"); - pass; - if (len(myinput[step]) == 0 and part1.find(step) == -1): - AvailableSteps.append(step); - - AvailableSteps.pop(0); - -print("##################################"); - -def RemoveDupsOrder(TheString): - a = ""; - for letter in TheString: - if not (letter in a): - a += letter; - return a; - -print(part1); - -part1 = RemoveDupsOrder(part1); - -print(part1); -- cgit v1.2.3