diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:15 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:15 +0300 |
commit | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch) | |
tree | da2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /util/string/cast.py | |
parent | 778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff) | |
download | ydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'util/string/cast.py')
-rw-r--r-- | util/string/cast.py | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/util/string/cast.py b/util/string/cast.py index 4787f6ef44..7c5daa1212 100644 --- a/util/string/cast.py +++ b/util/string/cast.py @@ -1,27 +1,27 @@ -print 'static const ui8 SAFE_LENS[4][15] = {' - - -def nb(n, b): - if n == 0: - return [0] - - digits = [] - - while n: - digits.append(int(n % b)) - n /= b - - return digits[::-1] - - -for p in (1, 2, 4, 8): - - def it1(): - for base in range(2, 17): - m = 2 ** (8 * p) - 1 - - yield len(nb(m, base)) - 1 - - print ' {0, 0, ' + ', '.join(str(x) for x in it1()) + '},' - -print '};' +print 'static const ui8 SAFE_LENS[4][15] = {' + + +def nb(n, b): + if n == 0: + return [0] + + digits = [] + + while n: + digits.append(int(n % b)) + n /= b + + return digits[::-1] + + +for p in (1, 2, 4, 8): + + def it1(): + for base in range(2, 17): + m = 2 ** (8 * p) - 1 + + yield len(nb(m, base)) - 1 + + print ' {0, 0, ' + ', '.join(str(x) for x in it1()) + '},' + +print '};' |