Login  Register

Programming Puzzles & Code Golf: What color is this?

Posted by MartinW on Jun 25, 2014; 4:53pm
URL: https://forum.world.st/Programming-Puzzles-Code-Golf-What-color-is-this-tp4764770.html

Hi,
i entered a Pharo version to this Code Golf contest: http://codegolf.stackexchange.com/a/32535/26615

"Given three number values - being the Red, Green, and Blue elements of a colour (eight bits per channel, 0 to 255) - your program must output the name of the given colour.“

My answer is:

| color colorNames nearestColorName |
color := Color r: 255 g: 0 b: 0.
colorNames := Color registeredColorNames.
nearestColorName := colorNames detectMin: [ :each | (Color named: each) diff: color].

But, the results are of mixed quality. All darker colors are named as gray, dark gray or very dark gray.

Is it my fault, the fault of Color’s diff: method or the fault of the available color names?

M.