[Moshe Zadka] > If we had an affine operation, instead of a linear one, we could have > [0, 2**n). I won't repeat the proof here but changing > > def f(i): > i <<= 1 > i^=1 # This is the line I added > if i >= 2**N: > i ^= MAGIC_CONSTANT_DEPENDING_ON_N > return i > > Makes you waltz all over [0, 2**n) if the original made you comple > (0, 2**n). [Tim] > But, Moshe! The proof would have been the most interesting part <wink>. Turns out the proof would have been intensely interesting, as you can see by running the attached with and without the new line commented out. don't-ever-trust-a-theoretician<wink>-ly y'rs - tim N = 2 MAGIC_CONSTANT_DEPENDING_ON_N = 7 def f(i): i <<= 1 # i^=1 # This is the line I added if i >= 2**N: i ^= MAGIC_CONSTANT_DEPENDING_ON_N return i i = 1 for nothing in range(4): print i, i = f(i) print i
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4