Cody

# Problem 42612. Convert ColorSpec string to RGB triplet

Solution 2617501

Submitted on 26 Jun 2020 by Moritz Weber
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
assert(isequal(str2rgb('y'),[1 1 0]))

fig = Figure (1) with properties: Number: 1 Name: '' Color: [1 1 0] Position: [508 656 583 437] Units: 'pixels' Show all properties

`  `
2   Pass
assert(isequal(str2rgb('m'),[1 0 1]))

fig = Figure (1) with properties: Number: 1 Name: '' Color: [1 0 1] Position: [509 654 583 437] Units: 'pixels' Show all properties

`  `
3   Pass
assert(isequal(str2rgb('c'),[0 1 1]))

fig = Figure (1) with properties: Number: 1 Name: '' Color: [0 1 1] Position: [509 654 583 437] Units: 'pixels' Show all properties

`  `
4   Pass
assert(isequal(str2rgb('r'),[1 0 0]))

fig = Figure (1) with properties: Number: 1 Name: '' Color: [1 0 0] Position: [509 654 583 437] Units: 'pixels' Show all properties

`  `
5   Pass
assert(isequal(str2rgb('g'),[0 1 0]))

fig = Figure (1) with properties: Number: 1 Name: '' Color: [0 1 0] Position: [509 654 583 437] Units: 'pixels' Show all properties

`  `
6   Pass
assert(isequal(str2rgb('b'),[0 0 1]))

fig = Figure (1) with properties: Number: 1 Name: '' Color: [0 0 1] Position: [509 654 583 437] Units: 'pixels' Show all properties

`  `
7   Pass
assert(isequal(str2rgb('w'),[1 1 1]))

fig = Figure (1) with properties: Number: 1 Name: '' Color: [1 1 1] Position: [509 654 583 437] Units: 'pixels' Show all properties

`  `
8   Pass
assert(isequal(str2rgb('k'),[0 0 0]))

fig = Figure (1) with properties: Number: 1 Name: '' Color: [0 0 0] Position: [509 654 583 437] Units: 'pixels' Show all properties

`  `
9   Pass
assert(isequal(str2rgb('yellow'),[1 1 0]))

fig = Figure (1) with properties: Number: 1 Name: '' Color: [1 1 0] Position: [509 654 583 437] Units: 'pixels' Show all properties

`  `
10   Pass
assert(isequal(str2rgb('magenta'),[1 0 1]))

fig = Figure (1) with properties: Number: 1 Name: '' Color: [1 0 1] Position: [509 654 583 437] Units: 'pixels' Show all properties

`  `
11   Pass
assert(isequal(str2rgb('cyan'),[0 1 1]))

fig = Figure (1) with properties: Number: 1 Name: '' Color: [0 1 1] Position: [509 654 583 437] Units: 'pixels' Show all properties

12   Pass
assert(isequal(str2rgb('red'),[1 0 0]))

fig = Figure (1) with properties: Number: 1 Name: '' Color: [1 0 0] Position: [509 654 583 437] Units: 'pixels' Show all properties

13   Pass
assert(isequal(str2rgb('green'),[0 1 0]))

fig = Figure (1) with properties: Number: 1 Name: '' Color: [0 1 0] Position: [509 654 583 437] Units: 'pixels' Show all properties

14   Pass
assert(isequal(str2rgb('blue'),[0 0 1]))

fig = Figure (1) with properties: Number: 1 Name: '' Color: [0 0 1] Position: [509 654 583 437] Units: 'pixels' Show all properties

15   Pass
assert(isequal(str2rgb('white'),[1 1 1]))

fig = Figure (1) with properties: Number: 1 Name: '' Color: [1 1 1] Position: [509 654 583 437] Units: 'pixels' Show all properties

16   Pass
assert(isequal(str2rgb('black'),[0 0 0]))

fig = Figure (1) with properties: Number: 1 Name: '' Color: [0 0 0] Position: [509 654 583 437] Units: 'pixels' Show all properties

17   Pass
assert(isequal(str2rgb('y'),[1 1 0]))

fig = Figure (1) with properties: Number: 1 Name: '' Color: [1 1 0] Position: [509 654 583 437] Units: 'pixels' Show all properties

18   Pass
assert(isequal(str2rgb('m'),[1 0 1]))

fig = Figure (1) with properties: Number: 1 Name: '' Color: [1 0 1] Position: [509 654 583 437] Units: 'pixels' Show all properties

19   Pass
assert(isequal(str2rgb('c'),[0 1 1]))

fig = Figure (1) with properties: Number: 1 Name: '' Color: [0 1 1] Position: [509 654 583 437] Units: 'pixels' Show all properties

20   Pass
assert(isequal(str2rgb('r'),[1 0 0]))

fig = Figure (1) with properties: Number: 1 Name: '' Color: [1 0 0] Position: [509 654 583 437] Units: 'pixels' Show all properties

21   Pass
assert(isequal(str2rgb('g'),[0 1 0]))

fig = Figure (1) with properties: Number: 1 Name: '' Color: [0 1 0] Position: [509 654 583 437] Units: 'pixels' Show all properties

22   Pass
assert(isequal(str2rgb('b'),[0 0 1]))

fig = Figure (1) with properties: Number: 1 Name: '' Color: [0 0 1] Position: [509 654 583 437] Units: 'pixels' Show all properties

23   Pass
assert(isequal(str2rgb('w'),[1 1 1]))

fig = Figure (1) with properties: Number: 1 Name: '' Color: [1 1 1] Position: [509 654 583 437] Units: 'pixels' Show all properties

24   Pass
str = 'adefhijlnopqstuvxz'; for ii=1:length(str) assert(isequal(str2rgb(str(ii)),[])) end

fig = Figure (1) with properties: Number: 1 Name: '' Color: 'none' Position: [509 654 583 437] Units: 'pixels' Show all properties rgb = []

25   Pass
assert(isequal(str2rgb('cyanide'),[]))

26   Pass
assert(isequal(str2rgb('yellowfin tuna'),[]))

27   Pass
assert(isequal(str2rgb('blue jays'),[]))