CS-Swap / Algoritmi-1

Repository destinato alla condivisione di materiale e soluzioni per gli esercizi ed esami assegnati dal Prof. Monti Angelo in preparazione all'esame di Algoritmi 1
8 stars 1 forks source link

Esame - #3 -31 Mar 2022 #75

Open rimaout opened 1 month ago

rimaout commented 1 month ago
image image
Soluzione Prof image image
alem1105 commented 1 month ago

Grossa porcata ma funziona 🦥

def es(p):
    s = p
    f = p
    while f.next != None:
        f = f.next
    while true:
        if f.val != s.val:
            return false
        f = f.prev
        if f == s:
            break
        s = s.next
        if f == s:
            break
    return true
Divine-Sunderer commented 1 month ago
def es3( p , s1 , s2 ):
    if p.next != None:
      return es3( p.next , s1+p.val , p.val+s2 )
    s1+=p.val
    s2=p.val+s2
    if s1==s2:
      return "SI"
    else: return "NO GAY"
ChiareDaze commented 1 month ago
def es(p):
    q=p
    while q.next!= None:
        q=q.next  
    while p.next != None and q.prec != None:
        if p.key == q.key:
            p=p.next
            q=q.prec
        else:
            return "NO"    
    return "SI"