Activity for Karl Knechtelâ€
Type | On... | Excerpt | Status | Date |
---|---|---|---|---|
Edit | Post #289604 | Initial revision | — | 8 months ago |
Answer | — |
A: Knight safe squares Python, 143 bytes ```python def r(i): y,z=65537,1+(1>10|(i&254s)z>>17|(i&127s)z>>15|(i&63s)y>>6)&(1<<64)-1 return 64-n.bitcount() ``` This is a port of trichoplax's Rust answer, written with relatively little comprehension. Because Python's integers are arbitrary sized, they cannot implic... (more) |
— | 8 months ago |
Comment | Post #286282 |
This approach also works in 3.x, if parentheses are added to the `print` usage - of course, this only ties the result from the simpler-to-understand approach, while that approach would waste a byte here (due to the need to separate `_` from `print`). (more) |
— | 8 months ago |
Edit | Post #289601 | Initial revision | — | 8 months ago |
Answer | — |
A: Reverse the bits in a Byte Python (3.6 and up), 32 bytes (unsigned integer I/O) ``` lambda x:int(f'{x:08b}'[::-1],2) ``` Input and output are `int` objects. This also reverses the bits in integers larger than 255, implicitly inferring their bit length from the number of bits needed to write them (even if that isn't a m... (more) |
— | 8 months ago |