See online:
Maze of size NxN, N the size of the unknown.
We started in the maze of any point, the point location is unknown, for some, it's coordinates of (0, 0).
Maze is only one exit.
Can reach any point of the maze, from start and there is only one way.
In starting, our direction is up. We can send to the left "L", turn right "R", "F" three kinds of instruction to move forward. Can send at most 16 instruction at a time. After the instruction execution, returns the current coordinates, coordinates are relative to the starting point, in the form of (x, y).
Coordinate system is as follows:
+ -> x
Left
Y
If arrive exports, return to the "OUT".
The most we can send 5000 instruction sequences.
When testing the size of the map between 5 ~ 20.
Scoring method:
For NxN maze, if out of the need to M instruction. And sent your program S instruction sequences, C instruction. That your score is: the N * M/(10 * S + C)
Maps for the following form as a starting point (R) :
+ - +. + - + - + - +
|... | |
+ - + - + - + + +.
|... | |
+ - + + - + + - +.
| R.. | |
+ + - + - + - + +
| | |
+ + + + + +
| | | |
+ - + - + - + - + - +
I very vegetables, enums and recursion, individual solution is as follows:
ferry=[[]]
I=0
Way_dict={}
Final_way=[]
Result_ways_dict={}
Def find_way (x, y, way_dict, result_ways_dict) :
Global I, j
I +=1
J=1
If x 1 & gt;=0 and x=0 and j Way_dict [r]. (I, j), append ((1 x, y))
Return find_way (1 x, y, way_dict result_ways_dict)
If x + 1 & lt; N and x>=0 and j>=0 and jJ +=1
Way_dict [r]. (I, j), append ((x + 1, y))
Return find_way (x + 1, y, way_dict result_ways_dict)
If x>=0 and x=0 and ferry [x] [j + 1)=="" and ((x, y + 1) not in way_dict [] (I, j)) and ((I, j) not in result_ways_dict. Keys ()) :
J +=1
Way_dict [r]. (I, j), append ((x, j + 1))
Return find_way (x, y + 1, way_dict result_ways_dict)
If x>=0 and xJ +=1
Way_dict [r]. (I, j), append ((x, j - 1))
Return find_way (x, y - 1, way_dict result_ways_dict)
If ((x or x====0 N) and 0 & lt;=yIf ferry [x] [y]=="" :
Result_ways_dict [r]. (I, j), append (way_dict [(I, j)])
Return
Return
Def handle (address) :
For l in range (1, len (address) :
If the address [l] [0] - address [l - 1] [0]==1:
Final_way. Append (" right ")
Elif address [l] [0] - address [l - 1] [0]==1:
Final_way. Append (" left ")
Elif address [1] - [l] address [1] [l - 1]==1:
Final_way. Append (" up ")
The else:
Final_way. Append (" down ")
Return final_way
Def the main () :
Lambda_list=[]
For I in range (N * * 2) :
Find_way (x, y, way_dict result_ways_dict) # (x, y) as the starting point coordinates
For j in result_ways_dict values () :
Lambda_list. Append (j)
Min_way=min (lambda_list)
Final_way=handle (min_way)
Print (final_way)
If __name__=="__main__" :
The main ()
If the process right, should be able to get high score
Still hope bosses more
CodePudding user response:
A good is good, send a post bai.