Problem 60951. Extra colors

Context
In the RGB color system used by Matlab, the color is a 1 x 3 / row vector [R G B] with each value/component R, G, B in the range 0 <= component <= 1. Each color defined is associated to its name and a one letter abridged version of it. For instance [1 0 0] matches with 'red' and 'r' . [0 1 1] matches with 'cyan' and 'c' and is a balanced mix of one component of green [0 1 0] with one component of blue [0 0 1]. Refer to the LineSpec field in the documentation of plot function for further information and the list of registered colors.
Your mission (should you choose to accept it ;-)
Provide the corresponding code (output vector) to one of these three new / given colors (input full string or abridged) :
  • 'violet' / 'v' is is an additive mix of one component of red with two components of blue;
  • 'purple' / 'p' is a balanced additive mix of one component of magenta with one component of black;
  • 'gray' / 'a' is a balanced additive mix of one component of white with one component of black.
Your algorithm must be case insensitive.
Forbidden functions
  • regexp
  • str2num
  • assignin
Please don't forget to like if you appreciated solving this problem :-)

Solution Stats

50.0% Correct | 50.0% Incorrect
Last Solution submitted on Jul 24, 2025

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers12

Suggested Problems

More from this Author42

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!