Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Open Labyrinth by UFO665
dctDirections = {"S": {"xOffset": [0, 1, 0, -1], "yOffset": [-1, 0, 1, 0], "char": ["W", "S", "E", "N"]},
"E": {"xOffset": [1, 0, -1, 0], "yOffset": [0, 1, 0, -1], "char": ["S", "E", "N", "W"]},
"N": {"xOffset": [0, -1, 0, 1], "yOffset": [1, 0, -1, 0], "char": ["E", "N", "W", "S"]},
"W": {"xOffset": [-1, 0, 1, 0], "yOffset": [0, -1, 0, 1], "char": ["N", "W", "S", "E"]}}
def move(mazeMap, curPos, sDirection):
dct = dctDirections[sDirection]
i = 0
while mazeMap[curPos[0] + dct["xOffset"][i]][curPos[1] + dct["yOffset"][i]] != 0:
i += 1
return {"pos": [curPos[0] + dct["xOffset"][i], curPos[1] + dct["yOffset"][i]], "char": dct["char"][i]}
def checkio(mazeMap):
curPos = [1, 1]
sPath = ""
sDirection = "S"
while curPos != [10, 10]:
res = move(mazeMap, curPos, sDirection)
curPos = res["pos"]
sPath += res["char"]
sDirection = res["char"]
return sPath
Dec. 14, 2015