The unfortunate part is that OpenAI cannot answer a question “show me most relevant stackoverflow links for my original question”.

Edit: however, I went on and grilled it further.

Question: Rewrite the golang code to solve the maze in constant time.

> I'm sorry, but it is not possible to solve a maze in constant time, as the time complexity of the problem depends on the size of the maze and the complexity of the search algorithm used.

> The A* algorithm and its variants are some of the most efficient and widely used algorithms for maze pathfinding, as they can provide near-optimal solutions in a reasonable amount of time. However, they still have a time complexity that is exponential in the worst case.

> There are other algorithms that can solve certain types of mazes faster than A, such as maze-solving algorithms that rely on distance transforms, flood fills, or topological sorting. However, these algorithms are typically specialized and may not work for all types of mazes.

> In summary, it is not possible to solve a general maze in constant time, but there are specialized algorithms that can solve certain types of mazes faster than A.

A couple of attempts to rephrase make the GPT a bit apologetic. It claims it's not possible to do anything about, eventually, when asked to solve the maze of size 20 times 20, it replies:

> With a maze size of 20x20, it is likely that the performance of the A* algorithm is already sufficient for practical purposes. However, if you encounter performance issues or have specific constraints that require faster solutions, you can consider implementing these optimization techniques.

So I ask it: What optimization techniques I could implement?

> There are several optimization techniques that can be implemented to improve the performance of the A* algorithm or other maze-solving algorithms. Here are some examples:

Use a more informed heuristic: The Manhattan distance heuristic used in the original code is a good general-purpose heuristic, but it may not be the most efficient for all maze configurations. Using a more informed heuristic, such as Euclidean distance or diagonal distance, can lead to faster convergence and fewer nodes being explored.

Implement early termination: If you only need a suboptimal solution or are willing to tolerate some error in the solution, you can terminate the search early once a "good enough" solution has been found. For example, you can set a maximum number of nodes to explore or a maximum search depth.

Prune search space: If you know some parts of the maze are not relevant to the solution, you can exclude those parts from the search space to reduce the number of nodes that need to be explored. For example, if you know the goal is located in a certain region of the maze, you can exclude nodes that are outside of that region from the search space.

Use a better data structure: The performance of the A* algorithm is heavily dependent on the data structure used to store the open and closed sets. Using a more efficient data structure, such as a binary heap or Fibonacci heap, can speed up the algorithm.

Parallelize the search: If you have access to multiple processing units, you can split the search space into multiple parts and run the A* algorithm in parallel. This can significantly reduce the search time, especially for large mazes.

> These techniques are not mutually exclusive, and you can combine them in different ways to achieve better performance. However, keep in mind that the optimal combination of techniques will depend on the specifics of the maze-solving problem and the available computational resources.

I still find it pretty good. It also proves my point I was making somewhere else. The challenge in applying GPT to software problems is knowing what to ask next and verifying that it gave a correct answer - as in, one needs to understand the problem without blindly trusting that what it said was right.