Added test for identifier/numeric conversion

develop
Sven Slootweg 13 years ago
parent 7da665f20f
commit 57187c621d

@ -0,0 +1,12 @@
import math
def to_numeric(identifier):
return ((ord(identifier[:1]) - 1) * 255) + (ord(identifier[1:]) - 1)
def to_identifier(numeric):
return chr(int(math.floor(numeric / 255) + 1)) + chr((numeric % 255) + 1)
print to_identifier(to_numeric("aa"))
print to_identifier(to_numeric("ab"))
print to_identifier(to_numeric("ac"))
print to_identifier(to_numeric("ad"))
Loading…
Cancel
Save