I need help with an algorithm, say I have a 2d grid of size n*n
, i need to find the max val path going from left to right making a
full revolution.
Here are the rules: the left and right of the grid are
connected, kind of like a pacman map where if you exit from the
left you come out from the right, same goes to the top and bottom.
You can only start at the top or bottom of the grid. This way you
can start at any column in the top or bottom. not just from the
left.
another rule is you can only move to the right, up right by 1,
or downright by 1 and must always end at the top or bottom of the
grid. The picture below will explain how it goes, please do this in
python with explanations:
1. You must start at the top or Consider the input given by the following grid: Start at the Top (1), Column Index (4) bottom of the grid. 3, 1, 1, 2, 8,6 Go Right (0) 2. You can only move: 6, 1, 8, 2, 7, 1 Go Up-Right (1) - Right (0) 5, 1, 3, 9, 9,5 Starting Column Up: Loops to Bottom Row - Up-Right (1) 5.9 8. 3, 2, 6 Right: Loops to Left Side - Down-Right (-1) 8 7,29 6,1 Steps Go Up-Right (1) 3. You must make 1 revolution The answer should be: 1, 1,0, 1, 1, 0, -1 Go Right (0) 4. You must end at the top or Go Down-Right (-1) bottom of the grid. TTop / Bottom The Total Score: 48 Goal: Find the path of the highest score
I need help with an algorithm, say I have a 2d grid of size n*n , i need to find the max val path going from left to rig
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am