Ad
Code
Diff
  • def even_or_odd(n):
        if n % 2 == 0:
            return 'Even'
        else :
            return 'Odd'
            
    • def even_or_odd(n):
    • if n==0:
    • return "Even"
    • elif n==1 or n==-1:
    • return "Odd"
    • if n<0:
    • return even_or_odd(n+2)
    • return even_or_odd(n-2)
    • if n % 2 == 0:
    • return 'Even'
    • else :
    • return 'Odd'
Code
Diff
  • def isMin(val,arr):
        match arr:
            case []:
                return True
            case _:
                return val<=arr[0] and isMin(val,arr[1:])
    
    def findMin(i,arr):
        match isMin(arr[i],arr):
            case True:
                return arr[i]
            case _:
                return findMin(i+1,arr)    
        
    def remove(target,arr):
        match arr:
            case []:
                return []
            case _:
                return arr[1:] if target==arr[0] else [arr[0]]+remove(target,arr[1:])
                
    def select(arr):
        match arr:
            case []:
                return []
            case _:
                m=findMin(0,arr)
                arr=remove(m,arr)
                return [m]+select(arr)
    print(1)
    • def isMin(val,arr):
    • match arr:
    • case []:
    • return True
    • case _:
    • return val<=arr[0] and isMin(val,arr[1:])
    • def findMin(i,arr):
    • match isMin(arr[i],arr):
    • case True:
    • return arr[i]
    • case _:
    • return findMin(i+1,arr)
    • def remove(target,arr):
    • match arr:
    • case []:
    • return []
    • case _:
    • return arr[1:] if target==arr[0] else [arr[0]]+remove(target,arr[1:])
    • def select(arr):
    • match arr:
    • case []:
    • return []
    • case _:
    • m=findMin(0,arr)
    • arr=remove(m,arr)
    • return [m]+select(arr)
    • return [m]+select(arr)
    • print(1)

rt

$a=1;