Thanks for the ValueError tip. I added it as well as a TypeError just in case the input comes in as a string. My skills are beginner level at best, tips like yours help a lot!
def firstMissingPositive(A): try: for x in range(1, max(A)+1): if x not in A: return x except: return A def firstMissingPositive(A): try: return next(x for x in range(1, max(A)+1) if x not in A) except: return A Two…
def findMissingPositive(A): A.sort() return min([x for x in range(A[0], A[-1]+1) if x not in A])
Thanks for the ValueError tip. I added it as well as a TypeError just in case the input comes in as a string. My skills are beginner level at best, tips like yours help a lot!
def firstMissingPositive(A): try: for x in range(1, max(A)+1): if x not in A: return x except: return A def firstMissingPositive(A): try: return next(x for x in range(1, max(A)+1) if x not in A) except: return A Two…
def findMissingPositive(A): A.sort() return min([x for x in range(A[0], A[-1]+1) if x not in A])