The awesomeness of a combinatorial explosion https://qiita.com/kaizen_nagoya/items/f309b0c2bb015bbc71c3
so,
I tried using graphillion https://qiita.com/cabernet_rock/items/50f955afc16287244154
Was made into a file.
Nothing comes out when I run it.
Added print.
gra.py
# https://qiita.com/cabernet_rock/items/50f955afc16287244154
#Import required modules
from graphillion import GraphSet
import graphillion.tutorial as tl
import time #Check the calculation time.
#Specify the size of the grid
universe = tl.grid(2, 2)
GraphSet.set_universe(universe)
tl.draw(universe)
start = 1 #Start position
goal = 9 #Goal position
paths = GraphSet.paths(start, goal)
print (len(paths))
#
key = 4 #1st place
treasure = 2 #2nd place
paths_to_key = GraphSet.paths(start, key).excluding(treasure)
treasure_paths = paths.including(paths_to_key).including(treasure)
print (len(treasure_paths))
#
universe = tl.grid(8, 8) #9x9 grid
GraphSet.set_universe(universe)
start = 1
goal = 81
s = time.time() #Calculation start time
print (paths = GraphSet.paths(start, goal))
time.time() - s #Calculation time
print (len(paths))
docker/ubuntu
# python3 gra.py
12
2
Traceback (most recent call last):
File "gra.py", line 26, in <module>
print (paths = GraphSet.paths(start, goal))
TypeError: 'paths' is an invalid keyword argument for this function
print (paths = GraphSet.paths(start, goal))
To
paths = GraphSet.paths(start, goal) print (paths)
change to.
Recommended Posts