Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Remove Accents by JeffReymond
def checkio(in_string):
"remove accents"
groups = (
((0x0c0, 0x0c5), "AA"),
((0x0c7, 0x0c7), "CC"),
((0x0c8, 0x0cb), "EE"),
((0x0cc, 0x0cf), "II"),
((0x0d1, 0x0d1), "NN"),
((0x0d2, 0x0d6), "OO"),
((0x0d9, 0x0dc), "UU"),
((0x0dd, 0x0dd), "YY"),
((0x0e0, 0x0e5), "aa"),
((0x0e7, 0x0e7), "cc"),
((0x0e8, 0x0eb), "ee"),
((0x0ec, 0x0ef), "ii"),
((0x0f0, 0x0f0), "oo"),
((0x0f1, 0x0f1), "nn"),
((0x0f2, 0x0f6), "oo"),
((0x0f9, 0x0fc), "uu"),
((0x0fd, 0x0fd), "yy"),
((0x0ff, 0x0ff), "yy"),
((0x100, 0x105), "Aa"),
((0x106, 0x10d), "Cc"),
((0x10e, 0x111), "Dd"),
((0x112, 0x11b), "Ee"),
((0x11c, 0x123), "Gg"),
((0x124, 0x127), "Hh"),
((0x128, 0x131), "Ii"),
((0x134, 0x135), "Jj"),
((0x136, 0x137), "Kk"),
((0x139, 0x142), "lL"),
((0x143, 0x14b), "nN"),
((0x14c, 0x151), "Oo"),
((0x154, 0x159), "Rr"),
((0x15a, 0x161), "Ss"),
((0x162, 0x167), "Tt"),
((0x168, 0x173), "Uu"),
((0x174, 0x175), "Ww"),
((0x176, 0x178), "Yy"),
((0x179, 0x17e), "zZ"),
((0x180, 0x185), "Bb"),
((0x186, 0x188), "Cc"),
((0x189, 0x18c), "Dd"),
((0x1a0, 0x1a1), "Oo"),
((0x1cd, 0x1ce), "aA"),
((0x1cf, 0x1d0), "iI"),
((0x1d1, 0x1d2), "oO"),
((0x1d3, 0x1dc), "uU"),
((0x1de, 0x1e1), "Aa"),
((0x1e4, 0x1e7), "Gg"),
((0x1e8, 0x1e9), "Kk"),
((0x1ea, 0x1ed), "Oo"),
((0x1f0, 0x1f0), "jj"),
((0x1f4, 0x1f5), "Gg"),
((0x1f8, 0x1f9), "Nn"),
((0x200, 0x203), "Aa"),
((0x204, 0x207), "Ee"),
((0x208, 0x20b), "Ii"),
((0x20c, 0x20f), "Oo"),
((0x210, 0x213), "Rr"),
((0x214, 0x217), "Uu"),
((0x218, 0x219), "Ss"),
((0x21a, 0x21b), "Tt"),
((0x21e, 0x21f), "Hh"),
((0x224, 0x225), "Zz"),
((0x226, 0x227), "Aa"),
((0x228, 0x229), "Ee"),
((0x22a, 0x231), "Oo"),
((0x232, 0x233), "Yy"),
((0x1e00, 0x1e01), "Aa"),
((0x1e02, 0x1e07), "Bb"),
((0x1e08, 0x1e09), "Cc"),
((0x1e0a, 0x1e13), "Dd"),
((0x1e14, 0x1e1d), "Ee"),
((0x1e1e, 0x1e1f), "Ff"),
((0x1e20, 0x1e21), "Gg"),
((0x1e22, 0x1e2b), "Hh"),
((0x1e2c, 0x1e2f), "Ii"),
((0x1e30, 0x1e35), "Kk"),
((0x1e36, 0x1e3d), "Ll"),
((0x1e3e, 0x1e43), "Mm"),
((0x1e44, 0x1e4b), "Nn"),
((0x1e4c, 0x1e53), "Oo"),
((0x1e4c, 0x1e53), "Oo"),
((0x1e54, 0x1e57), "Pp"),
((0x1e58, 0x1e5f), "Rr"),
((0x1e60, 0x1e69), "Ss"),
((0x1e6a, 0x1e71), "Tt"),
((0x1e72, 0x1e7b), "Uu"),
((0x1e7c, 0x1e7f), "Vv"),
((0x1e80, 0x1e89), "Ww"),
((0x1e8a, 0x1e8d), "Xx"),
((0x1e8e, 0x1e8f), "Yy"),
((0x1e90, 0x1e95), "Zz"),
((0x1e96, 0x1e96), "hh"),
((0x1e97, 0x1e97), "tt"),
((0x1e98, 0x1e98), "ww"),
((0x1e99, 0x1e99), "yy"),
((0x1e9a, 0x1e9a), "aa"),
((0x1ea0, 0x1eb7), "Aa"),
((0x1eb8, 0x1ec7), "Ee"),
((0x1ec8, 0x1ecb), "Ii"),
((0x1ecc, 0x1ee3), "Oo"),
((0x1ee4, 0x1ef1), "Uu"),
((0x1ef2, 0x1ef9), "Yy"))
out_string = ""
for i in in_string:
x = ord(i)
if 0x300 <= x <= 0x36f:
i = ""
else:
for (rs, re), subs in groups:
if rs <= x <= re:
i = subs[x % 2]
break
out_string += i
return out_string
#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
assert checkio(u"préfèrent") == u"preferent"
assert checkio(u"loài trăn lớn") == u"loai tran lon"
print('Done')
Oct. 7, 2014
Comments: