Design a Layered ASCII Canvas Command Processor

Quick Overview

Design a program for a fixed `10 x 6` ASCII canvas with layered filled rectangles. Make the API or object boundaries explicit, then cover invariants, edge cases, testing strategy, and operational trade-offs.

Design a Layered ASCII Canvas Command Processor

Company: Asana

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Onsite

# Design a Layered ASCII Canvas Command Processor Design a program for a fixed `10 x 6` ASCII canvas with layered filled rectangles. Commands draw a new frontmost rectangle, erase an area permanently from every rectangle, drag the topmost visible rectangle selected at a coordinate while preserving its layer, bring a selected rectangle to the front, and print the canvas. Erased cells move with their rectangle during drag. ### Constraints & Assumptions - Selection always uses the topmost visible, non-erased cell. - Commands outside the canvas must have a defined validation policy. ### Clarifying Questions to Ask - Does clipping apply when a rectangle is dragged partly outside the canvas? - What character represents an empty cell and how is a rectangle's character supplied? ### What a Strong Answer Covers - Layer ordering, stable rectangle identity, and per-shape erased-cell state. - Coordinate translation during drag and visibility-based selection. - Rendering complexity and tests for overlapping, erased, and moved shapes. ### Follow-up Questions - How would you implement undo without copying the canvas each time? - How would sparse storage change the design for a huge canvas?

Quick Answer: Design a program for a fixed `10 x 6` ASCII canvas with layered filled rectangles. Make the API or object boundaries explicit, then cover invariants, edge cases, testing strategy, and operational trade-offs.

|Home/Software Engineering Fundamentals/Asana
Asana logo
Asana
Aug 6, 2026, 12:00 AM
mediumSoftware EngineerOnsiteSoftware Engineering Fundamentals
1
0

Design a Layered ASCII Canvas Command Processor

Design a program for a fixed 10 x 6 ASCII canvas with layered filled rectangles. Commands draw a new frontmost rectangle, erase an area permanently from every rectangle, drag the topmost visible rectangle selected at a coordinate while preserving its layer, bring a selected rectangle to the front, and print the canvas. Erased cells move with their rectangle during drag.

Constraints & Assumptions

  • Selection always uses the topmost visible, non-erased cell.
  • Commands outside the canvas must have a defined validation policy.

Clarifying Questions to Ask Guidance

  • Does clipping apply when a rectangle is dragged partly outside the canvas?
  • What character represents an empty cell and how is a rectangle's character supplied?

What a Strong Answer Covers Guidance

  • Layer ordering, stable rectangle identity, and per-shape erased-cell state.
  • Coordinate translation during drag and visibility-based selection.
  • Rendering complexity and tests for overlapping, erased, and moved shapes.

Follow-up Questions Guidance

  • How would you implement undo without copying the canvas each time?
  • How would sparse storage change the design for a huge canvas?
Loading comments...