ClassicComputerScienceProblemsInPython
ClassicComputerScienceProblemsInPython copied to clipboard
Returned type should be int not float
Hello there,
I think, you should modify the type hints, since the xdist and ydist are both integer, so sum of them is going to be integer too, right?
https://github.com/davecom/ClassicComputerScienceProblemsInPython/blob/57d5f945e20eab0b88bea202d5a01e7318a5a613/Chapter2/maze.py#L100-L105
Probably; we return float because we want consistency with Euclidean distance, and so that the type hints match with the heuristic parameter of astar(). The alternative is a float() conversion at the end of distance().
Thanks for pointing this out.