10 """Convertit un nombre en binaire"""
12 res =[0 for i in range(n)]
27 acc = acc + 2**(n-i-1)
34 return sum([1 if ib[k] !=jb[k] else 0 for k in range(deuxExpN)])
36 st = "sc"+str(n)+"(X1):-\n"
37 for i in range(1,deuxExpN):
38 st += "\t mmult(X1,X"+str(i)+",X"+str(i+1)+"),\n"
39 st += "\t summ(X1,X2,S2),\n"
40 for i in range(2,deuxExpN):
41 st += "\t summ(S"+str(i)+",X"+str(i+1)+",S"+str(i+1)+"),\n"
42 st += "\t touspositifs(S"+str(deuxExpN)+").\n\n"
50 for i in range(deuxExpN):
52 for j in range(deuxExpN) :
53 XL.append('M'+str(i)+"X"+str(j))
58 st += "\t X=" +str(X).replace('\'','')+",\n"
60 # domaine des variables
61 for i in range(deuxExpN):
62 for j in range(deuxExpN):
64 st += "\t M"+str(i)+"X"+str(j)+" is 0 ,\n"
67 st += "\t M"+str(i)+"X"+str(j)+" in 0.."+str(n)+",\n"
69 st += "\t M"+str(i)+"X"+str(j)+" in 0..1"+",\n"
73 for i in range(deuxExpN):
75 for j in range(deuxExpN):
76 stl += "M"+str(i)+"X"+str(j) +"+ "
78 st += "\t "+stl + " #="+str(n)+" ,\n"
83 for i in range(deuxExpN):
85 for j in range(deuxExpN):
86 stlb += "M"+str(j)+"X"+str(i) +"+ "
88 st += "\t "+stlb + " #="+str(n)+" ,\n"
93 for i in range(deuxExpN):
94 for j in range(deuxExpN):
95 lbl.append('M'+str(i)+"X"+str(j))
97 st += "\t label("+ str(lbl).replace('\'','')+"),\n"
99 st+= "\t sc"+str(n)+"(X), \n"
100 st+= "\t open('res"+str(n)+".txt',append,Stream),\n"
101 st+= "\t write(Stream,X),\n"
102 st+= "\t close(Stream).\n\n"