I've identified a code snippet in an old python project that calculates Euclidean and Manhattan distances between two points. However, the current implementation involves duplicated code for both distance calculation methods, which can lead to maintenance issues and reduced readability.
The code includes separate functions for calculating Euclidean and Manhattan distances that could be jointed by one function, with each function containing duplicated logic when performing distance calculations each step.
Goals for Refactoring:
Refactoring the code by creating one combine function for both Manhattan and Euclidean distance calculations.
Improve code readability by reworking duplication distance logic.
Ensure efficient distance calculation across the project that supports the workflow for the rest of the project.
I've identified a code snippet in an old python project that calculates Euclidean and Manhattan distances between two points. However, the current implementation involves duplicated code for both distance calculation methods, which can lead to maintenance issues and reduced readability.
The code includes separate functions for calculating Euclidean and Manhattan distances that could be jointed by one function, with each function containing duplicated logic when performing distance calculations each step.
Goals for Refactoring:
Below is the attached code snippet of the issue.
Code Snippet: