I’ve been trying to solve Resistor Color Exercise, but i done a little search and seen thar all i had to do was define the colors at the enum:
typedef enum {
BLACK,
BROWN,
RED,
ORANGE,
YELLOW,
GREEN,
BLUE,
VIOLET,
GREY,
WHITE
} resistor_band_t;
And call it inside the function on resistor_color.c:
#include "resistor_color.h"
int color_code(resistor_band_t color) {
resistor_band_t resistor = color;
return resistor;
}
I asked to Gemini what to do, but all it said is that i have to include this to resolve the testing:
const resistor_band_t *colors(void) {
static const resistor_band_t all_colors[] = {
BLACK, BROWN, RED, ORANGE, YELLOW,
GREEN, BLUE, VIOLET, GREY, WHITE
};
return all_colors;
}
And when i asked why, it said that “my main code in the tests so all the code you should do is to complete it”…
Obviously, i wanted to understand what this piece of code do, rather than just accepting it
Edit: I tested this piece of code it recomended me, but it doesn’t work, i guess i was right to doubt