ΓΠ – Λύσεις των ασκήσεων 10, 11, 13 και 14 από το φυλλάδιο

από Γιάννης Κάτω από: 20-21 ΓΠ | Δεν επιτρέπεται σχολιασμός στο ΓΠ – Λύσεις των ασκήσεων 10, 11, 13 και 14 από το φυλλάδιο
# -*- coding: cp1253 -*-
#10.py πρώτο set
def einai_ayksousa( l ):
    for i in range( len(l)-1 ):
       if l[i] > l[i+1]:
           return False
    return True
def vres( key, lista ):
    if einai_ayksousa( lista ) == False:
        print "Prosoxh h lista den einai se ayksoysa seira"
        return -1
    first, last = 0, len(lista) - 1
    found, thesi = False, -1
    while first <= last and not found :
        thesi = ( first + last ) / 2
        if lista[ thesi ] == key :
            found = True
        elif lista[ thesi ]  l[i+1]:
           return False
    return True
def vres( key, lista ):
    if einai_ayksousa( lista ) == False:
        print "Prosoxh h lista den einai se ayksoysa seira"
        return []
    first, last = 0, len(lista) - 1
    found, thesi = False, -1
    while first <= last and not found :
        thesi = ( first + last ) / 2
        if lista[ thesi ] == key :
            found = True
        elif lista[ thesi ]  l[i+1]:
           return False
    return True
def vres( key, lista ):
    if einai_ayksousa( lista ) == False:
        print "Prosoxh h lista den einai se ayksoysa seira"
        return []
    first, last = 0, len(lista) - 1
    found, thesi = False, -1
    while first <= last and not found :
        thesi = ( first + last ) / 2
        if lista[ thesi ] == key :
            found = True
        elif lista[ thesi ] < key :
            first = thesi + 1
        else :
            last = thesi - 1
    if found:
        theseis = []
        for i in range( len(lista) ):
             if lista[i] == key :
                 theseis.append( i )
        return theseis #an to vrike
    else:
        return []



dokimi = ["apple", "bar", "code", "diamond", "echo", "eat", "friend"]
print vres( "echo", dokimi)



# -*- coding: cp1253 -*-
#14.py πρώτο set
def antimetathesi( a, b ):
    return b, a

a = raw_input("Dwse to A:")
b = raw_input("Dwse to B:")

a,b = antimetathesi(a, b)

print a
print b







Τα σχόλια δεν επιτρέπονται