"""Reproduce the explicitly hypothetical examples; standard library, no network.""" from collections import Counter from fractions import Fraction rows = [{'id': f'V{i+1}', 'controller': 'A' if i < 6 else 'B' if i < 9 else 'C', 'weight': 1} for i in range(12)] totals = Counter() for r in rows: totals[r['controller']] += r['weight'] print('Synthetic controllers:', dict(totals), 'largest share:', Fraction(max(totals.values()), sum(totals.values()))) print('Included in current history:', 102 - 100 + 1) print('Not included in current history:', 0) print('Reincluded at 104:', 104 - 104 + 1) print('Lookup failed:', None) a = '0x123456' + '0' * 30 + 'abcd' b = '0x123456' + '0' * 15 + '1' + '0' * 14 + 'abcd' assert len(a) == len(b) == 42 and a[:8] == b[:8] and a[-4:] == b[-4:] and a != b print('Synthetic full-string comparison:', a == b)