# Arup Guha
# 10/22/2020
# Example that calculates Manhattan Distance - using our own abs function!

# Pre-condition: x is an integer.
# Post-condition: the absolute value of x is returned.
def myabs(x):

    # Stays the same.
    if x >= 0:
        return x

    # If negative, we flip it.
    return -x

# Our program!
def main():
    
    # Get relevant values.
    x1 = int(input("Enter the x coordinate of your starting point.\n"))
    y1 = int(input("Enter the y coordinate of your starting point.\n"))
    x2 = int(input("Enter the x coordinate of your ending point.\n"))
    y2 = int(input("Enter the y coordinate of your ending point.\n"))

    # Calculate the Manhattan distance calling our own abs function!
    dist = myabs(x2-x1) + myabs(y2-y1)

    # Output result.
    print("You have to walk",dist,"blocks.")

# Run it!
main()
