3 ms·
These tricks are cool on their own, but they're really neat when you tie them together to solve larger (but still toy) puzzles. Two fun ones I can remember: ht
by Veedrac 9y ago
These tricks are cool on their own, but they're really neat when you tie them together to solve larger (but still toy) puzzles. Two fun ones I can remember:
https://www.reddit.com/r/programming/comments/4vctor/.../d5xl6vl/ https://www.reddit.com/r/programming/comments/4vctor/.../d5x...
https://cs.stackexchange.com/a/74888/16408 https://cs.stackexchange.com/a/74888/16408
The first asked
> Extra-extra credit can be earned for finding an algorithm that takes no more than O(log N) space and no more than
O(log N) time, where N is the number you are seeking for.
and the bit magic made it O(1) space and time. The second was on similar lines.
Unfortunately the bit fiddling at my day job tends to be a bit tamer ;).
- Veedrac 9y agoA clarification: this isn't to say such tricks are never used in a non-toy environment. There is, for example, this search algorithm I made for a serious purpose: https://stackoverflow.com/q/40141793/1763356 https://stackoverflow.com/q/40141793/1763356 The bit math is milder, but it still comes in handy.