On the Subject of Cell Lab
Luckily, modules don't do mitosis.
This module displays a lot of text. This is the data of a multicellular species. However, some bits of data have been lost. In order to solve the module, fix this data. Note: you will have to calculate H, S and V each only once.
The bottom three lines of text display the red, green and blue values in a range of 0-255. These must be converted to HSV.
RGB to HSV
In order to calculate the hue, you must first obtain the range it is in. In the table + indicates the highest channel, and - the lowest. If there are ties pick the first entry in the table in reading order that applies partially (255, 255, 0 can be +0- and 0+-, so we take the +0- entry)
Then use the following formula to get an offset value O. Minimum, maximum and the value in between are respectively labeled as C-, C+ and C*
O = (C*-C-)/(C+-C-) * 60
If your colour had an odd position in the table, add O to the left value. Otherwise subtract O from the right value. Round this value down to get your hue.
To get your saturation use the formula below and round down.
S = (C+-C-)/C+ * 100
To get your brightness use the formula below and round down.
V = C+/2.55
If any calculations did not make sense due to division by zero, ignore their values. They will not be used later.
Note: a normal HSV converter rounds differently. Please refrain from using them to avoid off-by-one errors.