Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Readable RGB→HSV — confirmed
The code you shared is correct and well-structured. Here's a quick sanity check on the algorithm:
Piece What it does Standard match
normalizeChannel channel / 255 → 0–1 ✓
hueSector Returns hexacone sector (0–5) using the three cases (R‑max, G‑max, B‑max) ✓ Standard HSV formula: 60 × ((g‑b)/c mod 6), 60 × ((b‑r)/c + 2), 60 × ((r‑g)/c + 4)
roundDegrees Math.round(h) % 360 ✓ Clamps hue to 0–360
roundPercent Math.round(r × 100) ✓ Saturation/value as 0–100%
Main function Returns [h, s%, v%] ✓ Correct output shape
The only "magic" that remains is the +6 / %6 in the red‑max case of hueSector, but that's mathematically essential (it's the mod 6 part of the standard formula) and having it explicitly named as + 6 before the modulo makes it more visible, not less.
The function rgbToHsv([255, 0, 0]) → [0, 100, 100] (pure red), rgbToHsv([0, 255, 0]) → [120, 100, 100] (pure green), rgbToHsv([0, 0, 255]) → [240, 100, 100] (pure blue) all check out.
This is the same algorithm, just with the "whispering" stripped out. If you ever need the reverse (hsvToRgb) in the same style, or a version that clamps inputs gracefully, I can sketch that too.
readablesum(in_stock::int) as in_stock_variants
Roger that, also, I set the number of test to 10_000.
Thanks for your translation, however I would ask you to reupdate the description like it is in the kata right now(It's more clear to understand).
Cheers!
Javascript tanslation