5 kyu
Convert A Hex String To RGB
6,181 of 15,971Krxtopher
Description:
When working with color values it can sometimes be useful to extract the individual red, green, and blue (RGB) component values for a color. Implement a function that meets these requirements:
- Accepts a case-insensitive hexadecimal color string as its parameter (ex.
"#FF9933"
or"#ff9933"
) - Returns a Map<String, int> with the structure
{r: 255, g: 153, b: 51}
where r, g, and b range from 0 through 255
Note: your implementation does not need to support the shorthand form of hexadecimal notation (ie "#FFF"
)
Example
"#FF9933" --> {r: 255, g: 153, b: 51}
Parsing
Strings
Algorithms
Similar Kata:
Stats:
Created | Nov 12, 2013 |
Published | Nov 12, 2013 |
Warriors Trained | 25748 |
Total Skips | 3544 |
Total Code Submissions | 32552 |
Total Times Completed | 15971 |
JavaScript Completions | 6181 |
CoffeeScript Completions | 59 |
Swift Completions | 432 |
Kotlin Completions | 777 |
Python Completions | 5346 |
Ruby Completions | 289 |
C Completions | 823 |
Java Completions | 1510 |
Dart Completions | 480 |
Scala Completions | 32 |
TypeScript Completions | 359 |
Total Stars | 343 |
% of votes with a positive feedback rating | 90% of 1401 |
Total "Very Satisfied" Votes | 1154 |
Total "Somewhat Satisfied" Votes | 224 |
Total "Not Satisfied" Votes | 23 |