def decrease(t, n): if(t == 0 or t > length(n)): return -1 k=list() for _ in range(t-1): s, n = c.reverse(n) k.append(s) s, n = c.reverse(n) k.append(s-1) k.reverse() for i in k: n = c.cantor(i,n) return n
def decode(n): k=list() while(n!=0): s, d = c.reverse(n) k.append(s) n=d return k
#sx(n) assert (cantor.sx(9) == 1) assert (cantor.sx(13) == 2) assert (cantor.sx(18) == 3) assert (cantor.sx(1) == 0) print("Ok sx") #dx(n) assert (cantor.dx(12) == 1) assert (cantor.dx(19) == 3) assert (cantor.dx(22) == 0) assert (cantor.dx(1) == 0) print("Ok dx") #reverse(n) assert (cantor.reverse(10) == (0, 3)) assert (cantor.reverse(13) == (2, 2)) assert (cantor.reverse(8) == (2, 1)) assert (cantor.reverse(23) == (5, 1)) print("ok reverse") #cantorZero assert (cantor.cantorZero(0, 0) == 0) assert (cantor.cantorZero(0, 3) == 9) assert (cantor.cantorZero(4, 0) == 10) assert (cantor.cantorZero(3, 2) == 17) print("Ok cantor zero") #reverse(n) assert (cantor.reverseZero(9) == (0, 3)) assert (cantor.reverseZero(12) == (2, 2))
def projection(t, n): if(t == 0 or t > length(n)): return -1 for _ in range(t): u, n = c.reverse(n) return u