import math
import colorsys


def step(r: int, g: int, b: int, repetitions=1) -> tuple:
    """
    Helper function to generate step sorted color diagram.
    Credits go to: https://www.alanzucconi.com/2015/09/30/colour-sorting/
    """

    lum = math.sqrt( .241 * r + .691 * g + .068 * b ) # weighting by luminosity
    h, s, v = colorsys.rgb_to_hsv(r,g,b)
    h2 = int(h * repetitions)
    v2 = int(v * repetitions)
    if h2 % 2 == 1:
        v2 = repetitions - v2
        lum = repetitions - lum

    return (h2, lum, v2)