Cody

Problem 42612. Convert ColorSpec string to RGB triplet

Solution 2179005

Submitted on 28 Mar 2020 by Takuma Mitamura
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]))

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Suggested Problems

More from this Author44

Community Treasure Hunt

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

Start Hunting!