File: ecrit_2011.tex, line 54
def remplissage (mat, x , y) : # ligne 1 dico = { (x,y):0 } # ligne 2 while len (dico) > 0 : # ligne 3 point = dico.popitem ()# retourne un élément du dictionnaire et le supprime x,y = point [0] # ligne 5 mat [x][y] = 1 # ligne 6 dico [x-1,y] = 0 # ligne 7 dico [x+1,y] = 0 # ligne 8 dico [x,y-1] = 0 # ligne 9 dico [x,y+1] = 0 # ligne 10
File: ecrit_2011.tex, line 69
... 118 41 13 118 40 13 118 34 8 118 34 7 118 41 13 118 40 13 118 34 8 118 34 7 118 41 13 ...
File: ecrit_2011.tex, line 97
def remplissage (mat, x , y) : # dico = { (x,y):0 } # while len (dico) > 0 : # point = dico.popitem ()# x,y = point [0] # if mat [x][y] == 1 : continue # ligne ajoutée mat [x][y] = 1 # dico [x-1,y] = 0 # dico [x+1,y] = 0 # dico [x,y-1] = 0 # dico [x,y+1] = 0 #
File: ecrit_2011.tex, line 113
def remplissage (mat, x , y) : # dico = { (x,y):0 } # while len (dico) > 0 : # point = dico.popitem ()# x,y = point [0] # mat [x][y] = 1 # if mat[x-1][y] == 0 : dico [x-1,y] = 0 # if mat[x+1][y] == 0 : dico [x+1,y] = 0 # if mat[x][y-1] == 0 : dico [x,y-1] = 0 # if mat[x][y+1] == 0 : dico [x,y+1] = 0 #
File: ecrit_2011.tex, line 128
def remplissage (mat, x , y) : int compte = 0 # ligne ajoutée dico = { (x,y):0 } while len (dico) > 0 : point = dico.popitem () x,y = point [0] if mat [x][y] == 1 : continue mat [x][y] = 1 dico [x-1,y] = 0 dico [x+1,y] = 0 dico [x,y-1] = 0 dico [x,y+1] = 0 compte += 1 # ligne ajoutée return comte # ligne ajoutée
File: ecrit_2011.tex, line 165
def resolution_simple (objets, sac) : objets.sort (reverse = True) solution = [] for o in objets : ... return solution
File: ecrit_2011.tex, line 192
def resolution (objets, sac) : if len (objets) == 1 : if objets [0] <= sac : return [ objets [0] ] else : return [] reduit = objets [1:] s1 = resolution (reduit, sac) s2 = resolution (reduit, sac - objets [0]) # ligne B t1 = sum(s1) t2 = sum(s2) + objets [0] # ligne C if sac >= t1 and (t1 >= t2 or t2 > sac) : return s1 elif sac >= t2 and (t2 >= t1 or t1 > sac) : return [ objets [0], ] + s2 obj = [2,4,7,10] sac = 15 print "solution ",resolution (obj, sac) # ligne A
File: ecrit_2011.tex, line 215
solution Traceback (most recent call last): File "examen2011.py", line A, in <module> print "solution ",resolution (obj, sac) File "examen2011.py", line B, in resolution s2 = resolution (reduit, sac - objets [0]) File "examen2011.py", line C, in resolution t2 = sum(s2) + objets [0] TypeError: 'NoneType' object is not iterable
File: ecrit_2011.tex, line 241
def resolution_simple (objets, sac) : objets.sort (reverse = True) solution = [] for o in objets : if sum(solution) + o <= sac : # ligne ajoutée solution.append (o) # ligne ajoutée return solution
File: ecrit_2011.tex, line 260
t2 = sum(s2) + objets [0] TypeError: 'NoneType' object is not iterable
File: ecrit_2011.tex, line 278
s2 = resolution (reduit, sac - objets [0]) # ligne B
File: ecrit_2011.tex, line 284
if sac >= t1 and (t1 >= t2 or t2 > sac) : return s1 elif sac >= t2 and (t2 >= t1 or t1 > sac) : return [ objets [0], ] + s2
File: ecrit_2011.tex, line 291
if sac >= t1 and (t1 >= t2 or t2 > sac) : return s1 elif sac >= t2 and (t2 >= t1 or t1 > sac) : return [ objets [0], ] + s2 else : return [] # ligne ajoutée