def is_valid(value, mode):
    """Return True if value is in range of map size.
    Mode: WIDTH or HEIGHT, depending what value is checked."""
    return False if value < 0 or value > mode-1 else True