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:

CreatedFeb 4, 2015
PublishedFeb 4, 2015
Warriors Trained10371
Total Skips1242
Total Code Submissions26515
Total Times Completed4480
JavaScript Completions1401
Haskell Completions219
C# Completions733
Python Completions1111
Java Completions1081
CoffeeScript Completions52
Ruby Completions236
C Completions48
Total Stars129
% of votes with a positive feedback rating91% of 473
Total "Very Satisfied" Votes407
Total "Somewhat Satisfied" Votes49
Total "Not Satisfied" Votes17
Ad
Contributors
  • jekt Avatar
  • jhoffner Avatar
  • Farami Avatar
  • Azuaron Avatar
  • bkaes Avatar
  • GiacomoSorbi Avatar
  • TellowKrinkle Avatar
  • kazk Avatar
  • hobovsky Avatar
  • solitude Avatar
  • trashy_incel Avatar
  • user3232161 Avatar
  • Just4FunCoder Avatar
  • farhanaditya Avatar
Ad