I've successfully decoded the solution to "Whodunit" from CS50 2018 (won't put the spoiler here, though will say the culprit's name has six letters), but will admit it was a lucky guess involving manipulation to the pixel colors. I actually can't recall exactly what I did (it involved adding more red, green, or blue if pixels were between x and y values of red), but the contrast of the solution still wasn't very high. I am seeking understanding of concepts now that I know the whodunit solution, and wondering if there's a more logical way of approaching this, rather than continued guess and check. I think there's a hint in the beginning of the instructions, about how one might solve this by putting that "piece of red plastic" over an image containing red. How would one go about doing this in computer-land? (Am I on the right track in thinking that replacing pure-red pixels (value rgbtRed = 0xFF) with white (0x00) is not enough? What about values that are slightly less red (say, 0xEF)? A switch out of OxFF with Ox00 would not account for those, right? Are loops involved? Some math? What if I wanted to change everything to a white background and black letters... (or specific other colors...)how would I go about that, for example? Is that even possible? If there is a way to detect RGB values/ranges of values for pixels, seems that would be helpful. Appreciative of any guidance.

1 Answer 1


The simplest way to emulate "putting the red cellophane over the picture" is to remove all but the red channel from every pixel. (ie, turn the blue and green channels off). That's 2 lines of code.

  • Ah - that makes sense, and now seems so obvious. For some reason, I was focused on "getting the red out." But obviously, there'd still be a lot of visible red with a piece of red plastic overlaid! smh The resulting image is now a red square with the verdict copy in a darker shade of red.
    – LippStick
    Sep 24, 2019 at 22:18
  • A lot of students overcomplicate it. :) Please accept my answer to remove this from the unsolved queue. Thanks.
    – curiouskiwi
    Sep 25, 2019 at 2:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .