diff options
| author | bthink <bthink@fake.com> | 2026-06-25 00:27:07 +0200 |
|---|---|---|
| committer | bthink <bthink@fake.com> | 2026-06-25 00:27:07 +0200 |
| commit | f25520e60fae2e642cc9a53a112c079cfae6d8a0 (patch) | |
| tree | 212174388102ebc039c4c1e102a0307dc742ee41 /gothpick.py | |
| parent | f04280131bc8a912dffe344b6b5c6f0d74681ab9 (diff) | |
added queue trimming
Diffstat (limited to 'gothpick.py')
| -rw-r--r-- | gothpick.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/gothpick.py b/gothpick.py index 764dbb9..8aa8e73 100644 --- a/gothpick.py +++ b/gothpick.py @@ -14,6 +14,7 @@ def lockpick(blocks, pinnumber, pinpos,connections): initialpins = [0]*blocks for p in pinpos: initialpins[p]=pinpos[p] + VisitedNodes=set() # queue items: # distance from solution # pinpositions @@ -24,6 +25,10 @@ def lockpick(blocks, pinnumber, pinpos,connections): # all are in the middle? if dist == 0: return path + + if path: + if (tuple(pins),path[-1]) in VisitedNodes: continue + VisitedNodes.add((tuple(pins),path[-1])) subqueue = [] #for each block for block in range(blocks): |
