f = lambda s:(max(s)-8)%39 for s in b'00000', b'123456', b'ff', b'4815162342', b'42', b'codegolf', b'0123456789abcdefghijklmnopqrstuvwxyz': print('%-39s -> %2d' % (s, f(s)))
Standard input is empty
b'00000' -> 1 b'123456' -> 7 b'ff' -> 16 b'4815162342' -> 9 b'42' -> 5 b'codegolf' -> 25 b'0123456789abcdefghijklmnopqrstuvwxyz' -> 36