THINK FIRST·CODE LATER

← All labs

MoSCoW release planner

Problem

Plan a release with MoSCoW priorities and a fixed capacity.

Input: first line capacity n; then n lines name priority effort where priority is M, S, C or W and effort is a positive integer (story points). Items are listed in the Product Owner's order.

Rules:

  1. All M items are required. If their total effort exceeds the capacity, print INFEASIBLE: Musts need X points, capacity Y and nothing else.
  2. Then go through the S items in input order and add each one that still fits in the remaining capacity; then the same for C items. An item that does not fit is skipped (later, smaller items may still fit).
  3. W items are never planned.

Output:

Planned: item1(M,8) item2(M,5) item3(S,8) ...
Deferred: itemA(S,13) itemB(C,3) ...
Won't: itemX ...
Used: U/CAPACITY points, Musts: P% of capacity

List items in input order within each line; if a list is empty print nothing after the colon. P is mustEffort * 100 / capacity with integer division. If P > 60, add a final line Warning: Musts exceed 60% of capacity.

Input:

40 6
login M 8
post M 8
search S 8
buddy S 21
emoji C 3
video W 30

Output:

Planned: login(M,8) post(M,8) search(S,8) emoji(C,3)
Deferred: buddy(S,21)
Won't: video
Used: 27/40 points, Musts: 40% of capacity

Data for this lab

Your program reads its data from standard input. Download the file, then give it to your program as shown below. Start with data set 1: its expected output is given.

s4-2-data-1.txt

40 6
login M 8
post M 8
search S 8
buddy S 21
emoji C 3
video W 30
What your program must print for s4-2-data-1.txt
Planned: login(M,8) post(M,8) search(S,8) emoji(C,3)
Deferred: buddy(S,21)
Won't: video
Used: 27/40 points, Musts: 40% of capacity

Run your program first, then open this and compare line by line: your output must contain these lines exactly.

How to give the file to my program

Terminal (macOS, Linux, or Windows Command Prompt), after compiling:

java Main < s4-2-data-1.txt

Windows PowerShell does not understand <:

Get-Content s4-2-data-1.txt | java Main

IntelliJ IDEA: Run → Edit Configurations → Redirect input from. Or simply paste the content of the file into the console when the program waits for input.

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.