From 0004ca9d83bc18282d4b2e39877a86999b21831e Mon Sep 17 00:00:00 2001 From: Bel LaPointe Date: Mon, 1 May 2023 07:04:56 -0600 Subject: [PATCH] try hyperloglog and find its only good at superbig --- hyperloglog.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 hyperloglog.py diff --git a/hyperloglog.py b/hyperloglog.py new file mode 100644 index 0000000..c158523 --- /dev/null +++ b/hyperloglog.py @@ -0,0 +1,23 @@ +import sys + +def main(args): + if not args: + args = [str(chr(c)) for c in range(ord('a'), ord('z'))] + + bucket = 0 + + for arg in args: + v = '{:b}'.format(hash(arg)).lstrip('-') + i = 63 - len(v) + for c in v: + if c != '0': + break + i += 1 + if i > bucket: + bucket = i + print(f'{i} <= {v} <= {arg}') + + print(f'result={2**bucket}') + +if __name__ == "__main__": + main(sys.argv[1:])