# Displays hexadecimal numbers in a simple 7-segment style
#  _       _   _       _   _   _   _   _   _       _       _   _ 
# | |   |  _|  _| |_| |_  |_    | |_| |_| |_| |_  |    _| |_  |_ 
# |_|   | |_   _|   |  _| |_|   | |_|  _| | | |_| |_  |_| |_  |  

import argparse

segs = {
    "0": [" _ ", "| |", "|_|"],
    "1": ["   ", "  |", "  |"],
    "2": [" _ ", " _|", "|_ "],
    "3": [" _ ", " _|", " _|"],
    "4": ["   ", "|_|", "  |"],
    "5": [" _ ", "|_ ", " _|"],
    "6": [" _ ", "|_ ", "|_|"],
    "7": [" _ ", "  |", "  |"],
    "8": [" _ ", "|_|", "|_|"],
    "9": [" _ ", "|_|", " _|"],
    "a": [" _ ", "|_|", "| |"],
    "b": ["   ", "|_ ", "|_|"],
    "c": [" _ ", "|  ", "|_ "],
    "d": ["   ", " _|", "|_|"],
    "e": [" _ ", "|_ ", "|_ "],
    "f": [" _ ", "|_ ", "|  "],
}


def display(n):
    n = n.lower()

    if any(ch not in segs for ch in n):
        raise ValueError("Input contains non-hex characters")

    for row in zip(*(segs[ch] for ch in n)):
        print(" ".join(row))


def main():
    parser = argparse.ArgumentParser(
        description="Display hexadecimal numbers in a 7-segment style."
    )

    parser.add_argument(
        "value",
        help="Hexadecimal value to display (0-9, A-F)"
    )

    args = parser.parse_args()

    try:
        display(args.value)
    except ValueError as e:
        parser.error(str(e))


if __name__ == "__main__":
    main()
