def valid(candidate):
    """Utility function that returns whether a pass permutation is valid"""
    permutation = str(candidate)
    # six digit number
    if not isinstance(candidate, int) or len(str(candidate)) != 6:
        # not a size digit number
        return False

    # increasing (next digit is > or ==)
    prev = permutation[0]
    for digit in permutation[1:]:
        # not increasing
        if digit < prev:
            return False
        prev = digit

    # at lease 2 adjacent digits are the same
    prev = permutation[0]
    for digit in permutation[1:]:
        # one adjacent match pair
        if digit == prev:
            return True
        prev = digit
    # Not matching adjacent digits - invalid
    return False