#!/usr/bin/env python3 import sys # Constants for ASCII art generation. # These can be adjusted, but must be consistent. SHAPE_HEIGHT = 5 SHAPE_WIDTH = 3 SEPARATOR = ".." # Placeholder templates for shapes based on hole count. # In these templates, '*' will be replaced by the specific character to draw with, # and ' ' will be replaced by a '.' to create holes. PLACEHOLDER_TEMPLATES = { 0: [ # 0-hole shape (a solid block) "***", "***", "***", "***", "***" ], 1: [ # 1-hole shape "***", "* *", "* *", "* *", "***" ], 2: [ # 2-hole shape "***", "* *", "***", "* *", "***" ] } # A mapping of characters to their defined hole count. # Characters not in this map default to 0 holes. HOLE_MAP = { 'A': 1, 'D': 1, 'O': 1, 'P': 1, 'Q': 1, 'R': 1, 'B': 2 } def get_hole_count(char): """Returns the number of holes for a given character based on the problem's rules.""" return HOLE_MAP.get(char, 0) def fill_template_row(template_row, char): """Fills a placeholder template row with the given character and dots.""" return template_row.replace('*', char).replace(' ', '.') def solve(): """ Main function to solve the problem. Reads the two color names, generates the corresponding captcha, and prints it. """ try: # Read the two color names from standard input. c1_human_readable = sys.stdin.readline().strip() c2_llm_readable = sys.stdin.readline().strip() except (IOError, ValueError): # Gracefully handle empty input or end-of-file. return if not c1_human_readable or not c2_llm_readable: return # 1. Determine the required hole count for each character in C1. c1_hole_counts = [get_hole_count(c) for c in c1_human_readable] # 2. Calculate the total width of the output image based on C1. num_chars_c1 = len(c1_human_readable) art_width = (num_chars_c1 * SHAPE_WIDTH) + \ ((num_chars_c1 - 1) * len(SEPARATOR)) if num_chars_c1 > 0 else 0 # 3. Generate and print the ASCII art lines for C1. for r in range(SHAPE_HEIGHT): line_parts = [] for i, hole_count in enumerate(c1_hole_counts): # Use the character from C1 itself to draw the shape. char_to_draw = c1_human_readable[i] template = PLACEHOLDER_TEMPLATES[hole_count] filled_row = fill_template_row(template[r], char_to_draw) line_parts.append(filled_row) # Join the parts of the line with the separator and print. print(SEPARATOR.join(line_parts)) # 4. Generate and print the text line for C2. text_pattern = c2_llm_readable + "." full_text_line = "" # Repeat the pattern until the line is long enough. while len(full_text_line) < art_width: full_text_line += text_pattern # Truncate the line to the exact width to form a rectangle. final_text_line = full_text_line[:art_width] print(final_text_line) if __name__ == "__main__": solve()