31
Amachua
8 24 43
5009/ 5695
Last seen 2 years ago
Member for 11 years, 5 months, 25 days
Difficulty Normal
Best reviews / Newest reviews
The Key-bryukh 8 1
Python 3.x way :) P.S. Why use tuple here? It works fine without it :) More
arithmetic-bunnychai 2
Happy to see that a O(1) solution exists! :) More
MyLabyrinth-SandeepShelke 1 1
If you want to avoid most of the if. You can use a dictionary like this: dic = {'N': (1,0), 'S':(-1,0), 'W':(0,-1), 'E':(0,1)} With this dictionary you can shrink getNextMove like this: def getNextMove(data, i, j, path): global visit hasChanged = False for d, vec More
To_ordinal-pythonist 1 1
Compare to mine your solution he's realy easy to read but it isn't O(1) ;) More
Finally !-Juge_Ti 1
You successfully handle exceptions . Nice solution! (Finally not alone.:D ) More
First-htamas 1 1
Nice solution! It's a good idea to use a global strategy for each ghost/Stephen position. Also, I would like to report a bug that I figured out when I've tested your code. In the attached file you can see that it crash for a specific case. I wander if you know why that happens? More
MyLabyrinth-SandeepShelke 1 1
visit = [[0,0]] No need to init visit with that value. More
MyLabyrinth-SandeepShelke 1 1
EAST, WEST, SOUTH, NORTH = 'E','W','S','N', Those variables aren't needed here. More
MyLabyrinth-SandeepShelke 1 1
Finally, you can change your getFirstMove like this: def getFirstMove(data, i, j, startDir): global visit visit += [[1+dic[startDir][0], 1+dic[startDir][1]]] return 1+dic[startDir][0], 1+dic[startDir][1], startDir More
MyLabyrinth-SandeepShelke 1 1
I hope those advises will be helpful :) More
MyLabyrinth-SandeepShelke 1 1
def visited(d): I don't understand why you create this function. "d in visit" already return a boolean ;) More
I do.-curious_k 1
Only four paragraphs? Why don't you write chapters or even books?! :) More
i_love_regexp-Kerulen
This task with regular expression... Good job! More
Three try solver-MadHatter 1
I didn't know the chinese remainder theorem. I think you can improve your algorithm if you take into account the first call ((1,5) in the example). Indeed, if they give you (1,8) you'll check two times the number 8. ;) More
First-henry14lb
Using dir as a variable name isn't clean. Futhermore, it isn't necessary to add the path in the visited list. It works fine just with the position and with that you just have to check if the current position is in this list => no need for the isVisited function ;) More
First-altarfinch 1
Why don't you use alkashi(b,c,a) instead of 180 - alkashi(a,b,c) - alkashi(a,c,b)? More
Simple Backtracking-Lingson
Congrats! You finally made it! :) More
First-Gennady
Seems we think the same way :) More
First-Bilou06 1
Your solution doesn't work with this case (see attached picture). More
Breadth First Search-Anne29
map = [] # Yeah, global data bitches. It's faster. Those comments... I love it :) More
1
2