← Duolingo Interview Insights

Duolingo·Software Engineer·Take-home Assignment·Intermediate

Intermediate
May 2026

Summary

Got a take-home style coding problem for a Software Engineer role at Duolingo. The whole thing was designing a simplified Animal Chess game from scratch using OOP, which was more involved than I expected for a single interview question.

Questions Asked (1)

Q1

Design and implement a simplified Animal Chess (Dou Shou Qi) game using object-oriented principles, including piece classes with movement and capture rules, a 9x7 board with different cell types, movement validation, turn handling, win conditions, and a basic API for board setup and move execution. Also write test cases covering board initialization, a capture move, and a multi-move turn simulation.

System DesignAPI & IntegrationsAlgorithms & Data Structures
Author's notes

This was a beast of a question.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the rules and scope, then outline a class design that separates concerns (Board, Cell, Piece hierarchy, Game). Walk through the core logic for movement, capture, and win conditions, and finish with a brief test plan covering initialization, a capture, and a multi-move turn.

Pro tip: Emphasize extensibility and testability: use dependency injection for the board and pieces, and write tests that simulate full turns to catch edge cases like illegal moves and win detection.

1. Clarify Requirements and Scope

Ask about board size, piece types, movement rules, and win conditions to ensure alignment. Confirm whether the API should support undo or only forward moves.

2. Design Class Structure

Define classes: Board (9x7 grid of Cells), Cell (type: land, water, trap, den), Piece (abstract with rank, position, and move validation), and Game (turn management, win detection). Use inheritance for piece types (e.g., Elephant, Lion).

3. Implement Movement and Capture Logic

For each piece, implement canMoveTo(destination) considering board boundaries, cell types (e.g., only rats enter water), and capture rules (rank comparison, special cases like rat captures elephant).

4. Handle Turns and Win Conditions

Game class alternates turns, validates moves, updates board, and checks win conditions: a piece reaches opponent's den or opponent has no legal moves. Return appropriate status from move execution.

5. Write Test Cases

Test board initialization (correct piece placement), a capture move (e.g., tiger captures cat), and a multi-move turn simulation (alternating moves until win). Use assertions to verify state after each move.

Key Points to Mention

  • Object-oriented principles: encapsulation, inheritance, polymorphism for pieces.
  • Board representation: 2D array of Cell objects with type enum.
  • Movement validation: check boundaries, cell type restrictions, and piece-specific rules.
  • Capture rules: rank comparison, special interactions (rat vs elephant, traps).
  • Turn management: track current player, enforce alternating turns, detect invalid moves.
  • Win conditions: reaching den or opponent has no legal moves; test with multi-move simulation.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.