Codage et décodage en base 36
from math import * car = ["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"] def code(n): global car code = [] while n != 0 : #Méthode des divisions succesives c = ((n % 36)) c = car[c] code.append(str(c)) n = n//36 code.reverse() code = "".join(code) #Transformation en chaine return code def decode(positions): global car result = [] valeur = 0 pos = list(positions) pos.reverse() for i,elt in enumerate(pos): valeur = car.index(elt) result.append(valeur*36**i) return(sum(result))