A canvas tool stores each pixel as one 32-bit number laid out as 0xRRGGBBAA: the highest 8 bits are red, then green, then blue, and the lowest 8 bits are alpha. The number is given as an unsigned value from 0 to 4294967295.
Write unpackColor(color) that returns [red, green, blue, alpha], each from 0 to 255.
Input: color = 4278190335 Output: [255,0,0,255]
4278190335 is 0xFF0000FF: red 255, green 0, blue 0, alpha 255.
Input: color = 0 Output: [0,0,0,0]
All bits are 0: transparent black.
0 <= color <= 4294967295Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #668 Unpack a Packed Color. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.