def generate_gradient():
    # Define the repeated pattern string
    s = "/\\/\\/\\/\\/\\" * 8  # Repeat the pattern 8 times to match the AWK example
    
    for colnum in range(77):  # Iterate over 77 columns
        # Calculate RGB values for the background color
        r = int(255 - (colnum * 255 / 76))
        g = int((colnum * 510 / 76))
        b = int((colnum * 255 / 76))
        if g > 255:
            g = 510 - g

        # Calculate RGB values for the foreground (inverse of background)
        inv_r = 255 - r
        inv_g = 255 - g
        inv_b = 255 - b

        # Print the character with background and foreground colors
        print(f"\033[48;2;{r};{g};{b}m\033[38;2;{inv_r};{inv_g};{inv_b}m{s[colnum]}\033[0m", end="")
    
    print()  # Add a newline at the end

if __name__ == "__main__":
    generate_gradient()
