Skip to main content
22 events
when toggle format what by license comment
Apr 30, 2022 at 8:39 comment added Neil Yeah, I was wondering which to suggest and picked the wrong one :-(
Apr 30, 2022 at 8:27 comment added ovs @Neil Apparently that needs parentheses around m:=1, not sure why. But while m:=1 works.
Apr 30, 2022 at 8:26 history edited ovs CC BY-SA 4.0
added 73 characters in body
Apr 30, 2022 at 0:22 comment added Neil For your main version, how about d+=m:=1? (Needs 3.8 of course.)
Apr 29, 2022 at 19:40 history edited ovs CC BY-SA 4.0
deleted 10 characters in body
Apr 29, 2022 at 8:06 comment added Neil I guess even while 1<l<=d: slows it down slightly...
Apr 29, 2022 at 4:38 comment added ovs @Neil The point of the second answer was to be as fast possible, but thanks to your comments I realized some of the bitwise stuff saves bytes on the main answer
Apr 29, 2022 at 4:33 history edited ovs CC BY-SA 4.0
added 25 characters in body
Apr 29, 2022 at 0:42 comment added Neil 130 bytes but it got slower...
Apr 29, 2022 at 0:08 comment added Neil I think if v>1:while l<=d: can be while 1<l<=d:.
Apr 29, 2022 at 0:05 comment added Neil I think n=~m;s=(n^(n&n-1)).bit_length()-1;d+=s;m>>=s can be while m%2:d+=1;m//=2.
Apr 28, 2022 at 15:44 history edited ovs CC BY-SA 4.0
added 592 characters in body
Apr 28, 2022 at 15:41 comment added ovs @loopywalt thanks, don't know how I didn't think of that
Apr 28, 2022 at 14:09 comment added loopy walt You can ex tract the lowest set bit using n&-n.
Apr 28, 2022 at 13:08 history edited ovs CC BY-SA 4.0
added 59 characters in body
Apr 28, 2022 at 12:45 history edited ovs CC BY-SA 4.0
added 24 characters in body
Apr 28, 2022 at 12:19 history edited ovs CC BY-SA 4.0
deleted 49 characters in body
Apr 28, 2022 at 12:12 history edited ovs CC BY-SA 4.0
added 212 characters in body
Apr 28, 2022 at 11:41 history edited ovs CC BY-SA 4.0
added 655 characters in body
Apr 28, 2022 at 10:29 history edited ovs CC BY-SA 4.0
added 80 characters in body
Apr 28, 2022 at 9:58 history edited ovs CC BY-SA 4.0
deleted 16 characters in body
Apr 28, 2022 at 9:49 history answered ovs CC BY-SA 4.0