This rgb function is incomplete. Complete it so that passing in RGB decimal values will result in a hexadecimal representation being returned. Vali...
For further actions, you may consider blocking this person and/or reporting abuse
Here is a short Python solution,
Output,
Scala, providing the shortest and most elegant solution so far 😎
Tests
In rust:
Rust Playground
GitHub Gist
A similar solution in R
Tests
JavaScript:
Haskell solution:
Python
You need to create a
rgb
function which takes three arguments. Also, this challenge didn't specify to put#
at the start.Here's a quick one-liner JS solution... It would look better with a helper function to validate min/max though :-)
edit:
Ok, so I came up with a nicer one-liner :-) but it requires using the funky Uint8ClampedArray, which normally shouldn't be used outside of canvas API... because it rounds values to nearest from 0 to 255... which is what we want! Without further ado:
In javascript
Here is the simple PHP solution:
BeanShell
Run this code using AJShA Android app
Here's my solution, with C