Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »

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