But the last test has no signature for the colors() function. And the solution requires to return an array of values on the heap. (static array) I find these quite advanced topics for an easy assignment without any hints.
Which invites people to look up solutions.
It would actually have been easier for me to calculate the resistor value based on 4 random colors.
I agree with that suggestion Jelle. I’ve seen one mentoree enhancing the exercise with resistance units and resistance value computation (3 significant digits * multiplier) and I was very happily surprised!
My personal understanding of this exercise is that it makes people think about how enums work, and that our manually generated array has the same “value” as the test one. One may also notice that the enum values need to be in the proper 0-9 range, which is fine as BLACK is 0 by default. This knowledge/realisation is a bit hidden between the lines though. I’m not sure if there is some other background/objective in this exercise.
The original Issue seems to be picked up on Github. As you can see here.
But in my opinion this test could lie closer to an actual application. I would expect to use a function to determine the actual resistor value. By testing the actual bands of a resistor. If you add the multiplier colors, that wouldn’t be so hard. A test of: