|
|
@ -11,15 +11,14 @@ for l in lines: |
|
|
|
di[l[1]] = [] |
|
|
|
di[l[1]] = [] |
|
|
|
di[l[1]].append(l[0]) |
|
|
|
di[l[1]].append(l[0]) |
|
|
|
|
|
|
|
|
|
|
|
print(di) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def travel(stack, node): |
|
|
|
def travel(stack, node): |
|
|
|
stack.append(node) |
|
|
|
stack.append(node) |
|
|
|
if node == 'end': |
|
|
|
if node == 'end': |
|
|
|
paths.append(stack.copy()) |
|
|
|
paths.append(stack.copy()) |
|
|
|
print(stack) |
|
|
|
|
|
|
|
for n in di[node]: |
|
|
|
for n in di[node]: |
|
|
|
if n not in stack or n.isupper(): |
|
|
|
#if n not in stack or n.isupper(): |
|
|
|
|
|
|
|
if (not(n in stack and any(stack.count(i) > 1 for i in [j for j in stack if j.islower()])) or n.isupper()) and n != 'start' and stack[-1] != 'end': |
|
|
|
travel(stack,n) |
|
|
|
travel(stack,n) |
|
|
|
stack.pop() |
|
|
|
stack.pop() |
|
|
|
|
|
|
|
|
|
|
@ -27,5 +26,5 @@ for start in di['start']: |
|
|
|
stack = ['start'] |
|
|
|
stack = ['start'] |
|
|
|
travel(stack, start) |
|
|
|
travel(stack, start) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print(len([i for i in paths if not any(i.count(j) > 1 for j in i if j.islower())])) |
|
|
|
print(len(paths)) |
|
|
|
print(len(paths)) |