# From one color to another

white turns to blue

blue turns to red

red turns to aquamarine

but green stays the same

People from StackOverflow might appreciate this one.

• Interesting question. So far this is all I have.. but I may be overthinking it: i.imgur.com/KuGALPa.png Feb 13, 2019 at 4:34
• @JoshCrozier - You're on the right track. Think about the weird quirks of the HTML spec. Feb 13, 2019 at 6:40
• In terms of HTML spec, Aquamarine is sort of the odd one out here. Now, "Aqua"...is constructed with "F" values and "0" values like all of the other colors in this riddle. In other words, I'm stumped... Feb 15, 2019 at 13:22
• "Aquamarine" is just an interpretation of the result. It's a blue-greenish color, that is probably closer the the "Aqua" color now that I look at it. All of the "after" colors are interpretations, but the "before" colors are 100% part of some accepted standard. Feb 15, 2019 at 21:25
• Jay's answer is correct, though I think it can be improved for people who aren't familiar the specific method they are referring to. Mar 14, 2020 at 7:07

There's no actual question here, but the transform involves

Parsing the colours as HTML hex values. Valid characters are going to be the numbers 0-9 and letters a-f. Everything else will be treated as 0. This would be how some browsers interpret bad or erroneous input, treating it as 0.

Converting the words, and padding out to a length of 3 or 6 characters:

white -> #0000e0
blue -> #b00e00
red -> #0ed
green -> #00ee00

Now the colour that each represents in (red, green, blue) format is

white -> (0%, 0%, 88%) Blue
blue -> (69%, 0%, 5%) Red
red -> (0%, 93%, 87%) Aquamarine
green -> (0%, 93%, 0%) Green

This must be about RGB. So I reformulate the task as such:

f(1,1,1) = (0,0,1)
f(0,0,1) = (1,0,0)
f(1,0,0) = (0,1,1)
f(0,1,0) = (0,1,0)
Note: aquamarine = green+blue aka cyan = (0,1,1)

Then the question becomes what is "f"?

Thinking further in terms of separate bits, and how we can obtain output bits from input bits:
output bit3 = bit1
output bit2 = bit1 xor bit2
output bit1 = not (bit1 or bit2)
Note: this uses logical or, not and xor.

So, finally:
f(bit1, bit2, bit3) = (not (bit1 or bit2), bit1 xor bit2, bit1)

P.S. This is just one of possible solutions, there are others and possibly more elegant ones.