# Colors weave into a spire of flames

Ok—jig's up—this one's only related to smash in name, but it'll give you something to burn your time with while you wait 'til December 7th

Given a color string s of form #rgb(in hex, so #000000 to #ffffff, dont worry about the three digit ones: #123) you must average the rgb values, and turn it into a flame color(heyy see what I did there?)

to turn an average hex number n(0-255) to a "flame color" you must return a string #rgbwith:

r = n

g = n - 144(the 144 is decimal, hex is 0x90) or if n - 144 is <0, then g = 0

b = 0

Given this is smash, we have to have items off. So no using arrays, maps, or sets(don't get into semantics about how strings are just abstracted arrays, I don't want to hear it)

1. Standard Loopholes are prohibited
2. Acceptable answers: a function which takes input through one input string and returns one output string
3. If the input string doesn't match the requirements provided above, your code MUST error out(doesn't matter what kind of Exception or Error)
4. This is code-golf, so the shortest(valid)answer (in each language) wins!
5. Bonus points for a one-liner 😎 (Not really tho, just cool points)
• Hiya, Michael! This is a nice idea for a challenge. I want to let you know that our community has accumulated some Things to avoid when writing challenges over time, and among them are “answer must be a function”, “do X without Y” (i.e. banning arrays and maps) and input validation. – Lynn Nov 8 '18 at 0:25
• You can read some pretty good cases under those links for why we've found those things generally detract from a challenge, or keep certain languages from competing. (Often they are “loaded” in a way that makes them not even make sense for all languages: for example, there's literally no distinction between strings and arrays of characters in many languages. Either way, it's such a blurred line, and all the bickering hasn't ever been worth it.) – Lynn Nov 8 '18 at 0:28
• I suggest you allow answers to perform I/O in whatever manner is convenient, with whatever tools they need, and I suggest you allow answers to assume that the input string they're given is always valid. That way, the “heart” of the task (the operation on #rrggbb strings) can really shine! – Lynn Nov 8 '18 at 0:32
• That said, the only unclear portion of the task I can put my finger on is whether we should compute (r+g+b)/3 rounding down to zero, or to the nearest integer. It's also always a good idea to include some test cases: example inputs along with the expected output. (In the future, the Sandbox can help you iron this stuff out in advance. It's really nifty!) Ack, I hope that all isn't too overwhelming! Welcome to PPCG. ^^ – Lynn Nov 8 '18 at 0:36
• I find the description semi-incoherent. Has it lost a paragraph or two of background / context? – Peter Taylor Nov 8 '18 at 14:24

# Perl 6, 108 bytes

{[$!=S/^\#(<[\d|A..F]>**2)**3$/{"#"~[~] ((sum("0x"X~$0)/3 X-0,144,255)Xmax 0)>>.fmt("%02x")}/,1/0][$! eq\$_]}


Try it online!

Anonymous code block that takes a string and returns a string if it is in a valid format, or a div by zero error otherwise. Though I'm not really sure how you're defining arrays,maps or sets, since my code uses sequences (Seq) and Matchs...

# Red, 96 bytes

func[s][c: hex-to-rgb do s n: c/1 + c/2 + c/3 / 3
to-hex/size n * 65536 +(256 * max 0 n - 144)6]


## Note:

It doesn't work in TIO (doesn't recognize hex-to-rgb- maybe it is not implemented for Linux yet).

## Tests within the Red console:

(first 3 taken from Jo King - thanks!):

>> print f "#012345"
#230000
>> print f "#6789AB"
#890000
>> print f "#AA89AB"
#9F0F00
>> print f "code golf"
*** Script Error: code has no value
*** Where: do
*** Stack: f hex-to-rgb