def mapVal(x, in_min, in_max, out_min, out_max):
    """
    Maps a value that is between in_min and in_max to
    a value between out_min and out_max
    @param in_min The minimum value that the input value could be
    @param in_max The maximum value that the input value could be
    @param out_min The minimum value that the output value could be
    @param out_max The maximum value that the output value could be
    @return A scaled value based on a given input
    """
    return int(
        (x - in_min) *
        (out_max - out_min) /
        (in_max - in_min) +
        out_min
    )