THINK FIRST·CODE LATER

← All labs

Risk register: exposure and priorities

Problem

Turn a list of risks into a prioritized register.

Input: lines id probability impactDays category until the end of input; probability is between 0 and 1, category is one word (AI, PEOPLE, EXTERNAL, TECH…).

Compute exposure = probability × impact. Print the risks sorted by exposure descending (on a tie, by id alphabetically), one per line:

id: P=0.40 I=20 exposure=8.00 [LEVEL] category

with LEVEL HIGH if exposure ≥ 5, MEDIUM if ≥ 2, else LOW. Then:

Total exposure: x.xx days
Suggested buffer: y days
By category: AI=.., EXTERNAL=.., ...

The buffer is the total exposure rounded up to a whole number of days. "By category" lists the sum of exposure per category with two decimals, categories in alphabetical order.

Input:

R1 0.4 20 AI
R2 0.5 10 PEOPLE
R3 0.2 25 EXTERNAL
R4 0.3 8 AI

Output:

R1: P=0.40 I=20 exposure=8.00 [HIGH] AI
R2: P=0.50 I=10 exposure=5.00 [HIGH] PEOPLE
R3: P=0.20 I=25 exposure=5.00 [HIGH] EXTERNAL
R4: P=0.30 I=8 exposure=2.40 [MEDIUM] AI
Total exposure: 20.40 days
Suggested buffer: 21 days
By category: AI=10.40, EXTERNAL=5.00, PEOPLE=5.00

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.