Seems like maybe there are some people in here who are expert in coding ?
I’m not at all expert but find it really interesting, and have been learning python alongside my sons.
When you live in the sticks like us, you have to make your own entertainment and so we have having a crack at the following challenge:
“A caterpillar starts at the top left corner of a square grid. Caterpillar biscuits are placed randomly in the grid. But the caterpillar can only see a certain number of squares in any direction. Write a program to guide the caterpillar to find all the biscuits in the shortest time.”
Any thoughts? Initially I was thinking of moving systematically through the grid on the shortest path (?spiral) with out and back detours to pick up the biscuits as they come into view.
My son seems to be taking the approach of mapping out the minimum number of waypoints the caterpillar needs to visit to see all the grid, then using a travelling salesman algorithm to optimize the route. With the added twist that whenever a biscuit comes into view, that is added as a new waypoint and the travelling salesman calculations repeated.
Who’s right and is there a better way?