14 Comments

User's avatar
PythagoRascal's avatar

Really neat little exercise! I briefly got confused in the video though. By choosing 3 or 0b11 as the example color value to test, we get the input again after the XOR and NOT. It took me a sec to realize that that only happens for 0b11.

I'm not working with binary every day and watched the video out-of-order because it is on YouTube, so I didn't immediately catch it. For binary beginners choosing a different test color might have helped, but I guess if you follow the course in order that should be basically no one. Great explanation though!

Expand full comment
Paul Kennedy's avatar

Since you can preprocess the color input, you can actually avoid the NOT by inverting the color bits first since ~(A XOR B) == A XOR ~B. So, if the color you want to check for is 0b01, you pass 0b10101010 to ContainsColor.

Expand full comment
12 more comments...

No posts