Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 87
def cbase(n,b): sol=[] while b<=n: sol.append(n%b) n=n//b sol.append(n) sole=sol[::-1] #aquí invierte la lista return sole
bobita=[[0,1,2],[1,2,0],[2,0,1]] #este es el autómata de rsiduos en base 3 def delta(i,j): # lee j estando en el estado i return bobita[i][j] def automat(daniela): EST=0 for ee in daniela: EST=delta(ee,EST) return EST
def tmor(b, po): #Sirve para sacar Thue-Morse en base 3 tona=[] for qq in range(b^po): tuta=cbase(qq,b) cont=automat(tuta) tona.append(cont) return tona
tmor(3,3)
[0, 1, 2, 1, 2, 0, 2, 0, 1, 1, 2, 0, 2, 0, 1, 0, 1, 2, 2, 0, 1, 0, 1, 2, 1, 2, 0]
automat([1,0,1])
2
tmor(2,4)
[0, 1, 1, 2, 1, 2, 2, 0, 1, 2, 2, 0, 2, 0, 0, 1]
cbase(5,2)
[1, 0, 1]
delta(1,2)
0
EST=0 for ee in [1,0,1]: EST=delta(ee,EST) print EST
2
bobito=[[0,1],[0,2],[3,2],[3,1]] #este es el autómata de paper folding def deltaa(i,j): # lee j estando en el estado i return bobito[i][j] def automata(daniela): EST=0 for ee in daniela: EST=deltaa(EST,ee) return EST def secpf(b, po): #ahora va a sacar la secuencia de b^po términos ( b=2) tona=[] for qq in range(1,b^po): #empieza desde 1 tuta=cbase(qq,b) cont=automata(tuta) tona.append(cont) return tona
secpf(2,4)
[1, 0, 2, 0, 1, 3, 2, 0, 1, 0, 2, 3, 1, 3, 2]
automata([1,1,0])
3
bobito[2][1]
2
bobito[2][0]
3
bobito[2]
[3, 2]
for ii in range(15): print cbase(ii,2)
[0] [1] [1, 0] [1, 1] [1, 0, 0] [1, 0, 1] [1, 1, 0] [1, 1, 1] [1, 0, 0, 0] [1, 0, 0, 1] [1, 0, 1, 0] [1, 0, 1, 1] [1, 1, 0, 0] [1, 1, 0, 1] [1, 1, 1, 0]
a=[1,2,2] print a.reverse()
None
b=a.extend([1])
print b
None
bi=reversed(a)
cbase(16,2)
[1, 0, 0, 0, 0]
def paperf(n): #ahora traduce tequ=[] for nu in secpf(2,n): if nu==0 or nu==1: tequ.append(1) if nu==2 or nu==3: tequ.append(0) return tequ
paperf(5)
[1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0]
pper(6)