THINK FIRST·CODE LATER

← All labs

A Kanban board that enforces WIP limits

Problem

Simulate StudyBuddy's Kanban board with four columns in this order: TODO, DOING, REVIEW, DONE. DOING and REVIEW have WIP limits; TODO and DONE are unlimited.

Input: first line limitDoing limitReview. Then commands until the end of input:

  • ADD card — put a new card in TODO → print ADD card -> TODO
  • MOVE card COLUMN — move a card to another column:
    • if the card does not exist → MOVE card rejected: no such card
    • if the target is full → MOVE card rejected: COLUMN is full (limit L)
    • a card may only move one column forward, or back to any earlier column; otherwise → MOVE card rejected: cannot skip columns
    • otherwise → MOVE card -> COLUMN
  • SHOW — print one line per column: COLUMN (n): card1 card2 ... (cards in the order they entered the column; if empty, nothing after the colon).

Card names are unique words; ADD of an existing card prints ADD card rejected: duplicate.

Input:

1 1
ADD login
ADD quiz
MOVE login DOING
MOVE quiz DOING
MOVE login DONE
MOVE login REVIEW
MOVE quiz DOING
SHOW

Output:

ADD login -> TODO
ADD quiz -> TODO
MOVE login -> DOING
MOVE quiz rejected: DOING is full (limit 1)
MOVE login rejected: cannot skip columns
MOVE login -> REVIEW
MOVE quiz -> DOING
TODO (0):
DOING (1): quiz
REVIEW (1): login
DONE (0):

Apply the checks in exactly this order: no such card, then cannot skip columns, then full. Moving a card to the column it is already in is allowed and changes nothing.

Write it here or in your IDE, then paste it. Compile and test it yourself before comparing. Your code stays in your browser — it is never sent to or stored on the server.