« first day (338 days earlier)      last day (316 days later) » 

1:22 PM
Can anyone break this down and explain how it does what it does?
i(char*s){*s^=*s?i(s+1),1:0;}
It's C code. I mean, I'm OK with C generally but I'm not a guru and I can't wrap my head around what this does.
I'm having trouble understanding what's inside the set braces.
 
1:40 PM
I wish I knew enough C to help - there's a few people who frequent this chatroom which might be able to, but most of them are asleep around this time
So you could probably either wait for them to wake up or try posting in the Nineteenth Byte in the meantime instead
@user3707023 (pinging for notifications)
 
2:10 PM
@user3707023 so s points at the first character of the input string and *s will be one of 48 (character 0), 49 (character 1) or 0 (null which terminates the string). the easiest way to swap the 48s and 49s is to XOR them with 1 (which toggles the least significant bit). that's basically *s^=1;.
in order to loop, the solution uses recursion. if *s isn't zero yet (that is, we're not at the end), i is called recursively on the remainder of the string before 1 is returned to toggle the current character. otherwise the ternary operator returns 0 so as not to mess with the null which terminates the string.
 
@MartinEnder Awesome, thank you for that response. I have to admit I still haven't fully understood it, but I will read your explanation several more times tonight and tomorrow and hopefully I can fully understand how it works.
By the way, I chose to post this question here rather than making a normal stack overflow question because I figured I would just get downvotes... You know what I'm talking about right? My follow-up question is... why specifically does this kind of question get downvoted and is this the best place on the net to be asking this question about that line of code?
 
2:41 PM
I think it would have been worth a try on SO. If you explain in a bit more detail which parts of the code you're having trouble with and what you've tried to figure it out, I think it should be a perfectly acceptable question. They don't like questions asking for how to golf things, but I don't think they have a problem with trying to understand why obscure code works.
 
3:21 PM
Cool, thanks
 
 
2 hours later…
5:22 PM
managed to get a hasty ><> solution in for almost alphabetical before deadline, should be improvable
 
5:52 PM
@MitchSchwartz looking at your alternative Ruby solution it seems you did find the flaw in the test cases without being aware of it ;)
 
oh yeah well originally i just removed the one element and not all instances of it
but since arr - other_arr is a built in
i did that as an approximation, it got accepted, and i forgot that i did it
then i saw it when i went back
that's how my gs2 solution works, and i also got a 20 byte gs solution like tails, that i didn't submit
my original gs2 solution just removed the one element though
it was 13 bytes i think, i'd have to go back and check to be sure
i mean that i forgot that i didn't check to make sure it always works, and not just for the given test data
 
Yeah, it would be problematic for test cases like bbab.
 
er, yeah, or just bba
 
oh right
 
(deleted the first "or just bba" cause i wasn't sure -- i guess you can see deleted messages in chat though)
cause i was looking at bba while testing, but atm was just going off memory
so the "er, yeah" is referring to me deleting my message and having to rewrite it
 
6:09 PM
I figured :)
 
6:27 PM
@Sp3000 is that the same weakness you were talking about earlier?
 
6:38 PM
Yeah, just what Martin said
 
 
1 hour later…
7:40 PM
Definitely should have gotten ruby, oh well
 

« first day (338 days earlier)      last day (316 days later) »