7 kyu
254 shades of grey
1,401 of 4,480jekt
Description:
Why would we want to stop to only 50 shades of grey? Let's see to how many we can go.
Write a function that takes a number n as a parameter and return an array containing n shades of grey in hexadecimal code (#aaaaaa
for example). The array should be sorted in ascending order starting with '#010101'
, '#020202'
, etc. (using lower case letters).
Examples:
n = 1: ["#010101"]
n = 10: ["#010101", "#020202", "#030303", "#040404", "#050505", "#060606", "#070707", "#080808", "#090909", "#0a0a0a"]
As a reminder, the grey color is composed by the same number of red, green and blue: #010101
, #aeaeae
, or #555555
.
Black: #000000
and white: #ffffff
are not accepted values.
When n
is negative, just return an empty array.
If n
is higher than 254, just return an array of 254 elements.
Have fun!
Fundamentals
Strings
Algorithms
Stats:
Created | Feb 4, 2015 |
Published | Feb 4, 2015 |
Warriors Trained | 10371 |
Total Skips | 1242 |
Total Code Submissions | 26515 |
Total Times Completed | 4480 |
JavaScript Completions | 1401 |
Haskell Completions | 219 |
C# Completions | 733 |
Python Completions | 1111 |
Java Completions | 1081 |
CoffeeScript Completions | 52 |
Ruby Completions | 236 |
C Completions | 48 |
Total Stars | 129 |
% of votes with a positive feedback rating | 91% of 473 |
Total "Very Satisfied" Votes | 407 |
Total "Somewhat Satisfied" Votes | 49 |
Total "Not Satisfied" Votes | 17 |