def normalize(x, m0, m1, r0, r1):
    """
    Normalizes x which varies from the range [m0, m1] to the range [r0, r1]
    @params: int, int, int, int, int
    @return: float
    """
    return (r1 - r0) * ((x - m0) / (m1 - m0)) + r0