def _map(x, in_min, in_max, out_min, out_max):
    """
    Re-maps a number from one range to another
    :param x: the number to map
    :param in_min: the lower bound of the value’s current range
    :param in_max: the upper bound of the value’s current range
    :param out_min: the lower bound of the value’s target range
    :param out_max: the upper bound of the value’s target range
    :return: the mapped value
    """
    return int((x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min)