PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches

Quick Overview

This question evaluates the ability to implement text rendering and string/array manipulation concepts, including glyph concatenation with inter-character spacing, newline-preserved blocks, blank glyph rendering for spaces, and handling of unsupported characters.

  • medium
  • Asana
  • Coding & Algorithms
  • Software Engineer

Implement an ASCII Art Printer

Company: Asana

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

Implement an ASCII art printer. A font defines each supported character as a glyph with the same height. A glyph is a list of equal-length text rows. Given an input string and the font, return the rendered ASCII-art output. Requirements: - Render characters by concatenating corresponding glyph rows horizontally. - Insert one blank column between adjacent characters on the same input line. - Preserve newline characters in the input by starting a new block of glyph rows. - Render a space character as a blank glyph of the font height. - For an unsupported character, either return an error or render a configured placeholder; document your choice. - Do not print directly to stdout; return the final string or list of lines. Example font of height 3: | Character | Row 1 | Row 2 | Row 3 | |---|---|---|---| | `A` | ` # ` | `# #` | `###` | | `B` | `## ` | `# #` | `## ` | Input `AB` with one-column spacing renders: ` # ## ` `# # # #` `### ## ` Constraints: let `S` be the total number of characters in the rendered output. The implementation should run in O(S) time.

Quick Answer: This question evaluates the ability to implement text rendering and string/array manipulation concepts, including glyph concatenation with inter-character spacing, newline-preserved blocks, blank glyph rendering for spaces, and handling of unsupported characters.

Implement an ASCII art printer. You are given a text string and a font, where the font maps each supported character to a glyph. A glyph is a list of text rows. In this problem, all glyphs in the font have the same height H and the same width W. To render a line of text, concatenate the corresponding glyph rows horizontally and insert exactly one blank column between adjacent characters. Preserve newline characters in the input by starting a new block of H output rows for each input line. A space character must be rendered as a blank glyph of size H x W. For unsupported characters, this problem uses a configurable placeholder: if placeholder is not None, render the placeholder glyph; otherwise raise a ValueError. Return the final rendered string and do not print to stdout.

Constraints

  • font contains at least one glyph
  • 1 <= H, W <= 10
  • Every glyph in font has exactly H rows, and every row has length W
  • 0 <= len(text) <= 10^4
  • Your algorithm should run in O(S) time, where S is the number of characters in the returned output

Examples

Input: ('AB', {'A': [' # ', '# #', '###'], 'B': ['## ', '# #', '## ']}, None)

Expected Output: ' # ## \n# # # #\n### ## '

Explanation: Rows 1, 2, and 3 of A and B are concatenated with one extra blank column between the two glyphs.

Input: ('A\nB', {'A': [' # ', '# #', '###'], 'B': ['## ', '# #', '## ']}, None)

Expected Output: ' # \n# #\n###\n## \n# #\n## '

Explanation: The newline in the input starts a new block of 3 glyph rows, so A is rendered first and B is rendered below it.

Input: ('A B', {'A': [' # ', '# #', '###'], 'B': ['## ', '# #', '## ']}, None)

Expected Output: ' # ## \n# # # #\n### ## '

Explanation: The space character is rendered as a blank 3x3 glyph, and there is still one blank column between adjacent characters.

Input: ('AZ', {'A': [' # ', '# #', '###'], '?': ['???', ' ?', ' ? ']}, '?')

Expected Output: ' # ???\n# # ?\n### ? '

Explanation: Z is not in the font, so the placeholder glyph for ? is used instead.

Input: ('', {'A': [' # ', '# #', '###']}, None)

Expected Output: ''

Explanation: An empty input string produces an empty output string.

Hints

  1. Render one input line into H separate row buffers, one buffer for each glyph row.
  2. Avoid repeated string concatenation inside loops; collect fragments in lists and join them at the end.
Last updated: May 23, 2026

Loading coding console...

PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Solve a Jigsaw Puzzle - Asana (medium)
  • Compute Products Excluding Each Index - Asana (medium)
  • Implement ASCII canvas and solve two data problems - Asana (medium)
  • Implement core puzzle/array/grid routines - Asana (medium)