ClassicComputerScienceProblemsInPython icon indicating copy to clipboard operation
ClassicComputerScienceProblemsInPython copied to clipboard

Returned type should be int not float

Open GreatBahram opened this issue 6 years ago • 1 comments

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

GreatBahram avatar Nov 01 '19 17:11 GreatBahram

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.

davecom avatar Nov 22 '19 00:11 davecom