Ad
  • Custom User Avatar

    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.

  • Custom User Avatar
    • what are the top several qualities of this code that merit the distinction of being readable
    • what are those that render it less so
  • Custom User Avatar

    sum(in_stock::int) as in_stock_variants

  • Custom User Avatar

    Roger that, also, I set the number of test to 10_000.

  • Custom User Avatar

    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).

    • Also will be great to add a print method, to represent the chess board and where are the rooks positioned
      Cheers!
  • Custom User Avatar