File size: 2,291 Bytes
5fed0fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
"""Colorful terminal output utilities."""

import sys

# ANSI color codes
RESET = "\033[0m"
BOLD = "\033[1m"
DIM = "\033[2m"

# Colors
RED = "\033[31m"
GREEN = "\033[32m"
YELLOW = "\033[33m"
BLUE = "\033[34m"
MAGENTA = "\033[35m"
CYAN = "\033[36m"
WHITE = "\033[37m"

# Bright colors
BRIGHT_RED = "\033[91m"
BRIGHT_GREEN = "\033[92m"
BRIGHT_YELLOW = "\033[93m"
BRIGHT_BLUE = "\033[94m"
BRIGHT_MAGENTA = "\033[95m"
BRIGHT_CYAN = "\033[96m"

# Check if terminal supports colors
_USE_COLOR = hasattr(sys.stdout, "isatty") and sys.stdout.isatty()


def _c(text: str, color: str) -> str:
    """Apply color to text if terminal supports it."""
    if not _USE_COLOR:
        return text
    return f"{color}{text}{RESET}"


def bold(text: str) -> str:
    return _c(text, BOLD)


def dim(text: str) -> str:
    return _c(text, DIM)


def red(text: str) -> str:
    return _c(text, RED)


def green(text: str) -> str:
    return _c(text, GREEN)


def yellow(text: str) -> str:
    return _c(text, YELLOW)


def blue(text: str) -> str:
    return _c(text, BLUE)


def magenta(text: str) -> str:
    return _c(text, MAGENTA)


def cyan(text: str) -> str:
    return _c(text, CYAN)


def success(text: str) -> str:
    return _c(text, BRIGHT_GREEN)


def error(text: str) -> str:
    return _c(text, BRIGHT_RED)


def warning(text: str) -> str:
    return _c(text, BRIGHT_YELLOW)


def info(text: str) -> str:
    return _c(text, BRIGHT_CYAN)


def header(text: str) -> str:
    return _c(text, BOLD + BRIGHT_MAGENTA)


def section(text: str) -> str:
    return _c(text, BOLD + CYAN)


def model_name(text: str) -> str:
    return _c(text, BRIGHT_BLUE)


def problem_name(text: str) -> str:
    return _c(text, YELLOW)


def solution_name(text: str) -> str:
    return _c(text, GREEN)


# Semantic printers
def print_header(text: str) -> None:
    line = "=" * 60
    print(f"\n{header(line)}")
    print(header(text))
    print(f"{header(line)}\n")


def print_section(text: str) -> None:
    print(section(text))


def print_success(text: str) -> None:
    print(success(f"✓ {text}"))


def print_error(text: str) -> None:
    print(error(f"✗ {text}"))


def print_warning(text: str) -> None:
    print(warning(f"⚠ {text}"))


def print_info(text: str) -> None:
    print(info(f"→ {text}"))