HomeChallengesRepsProblemsLeaderboardTake a challenge

Five levels deep, and the transfer is at the bottom

A payout service where the one line that moves money is indented five times. Flatten it — and decide, while you are there, which of these five conditions is a bug and which is a business outcome.

Beginner15 min on the clock5 graded checks · 100 pointsCode Someone Else Can Change, in C#

See alsoThe pyramid in the middle of the functionThe same pyramid in JavaScript, where the four error responses are checked by running them.

Graded by reading your code against the checklist below.

What you build

  • The two null arguments throw rather than returning a result
  • The three domain conditions still return PayoutResult.Failure
  • No else branch anywhere
  • Conditions inverted, not reordered
  • ExecuteTransfer sits at the method’s baseline indentation

Done means

A caller can tell a defect from a refusal, and the transfer is readable in one pass.

How it is graded

Published in full, before you start — every point is one of these and there is nothing else.

  1. A missing argument throws instead of returning a result+25Failing in a shape callers can read
  2. The three business refusals still return Failure+25Failing in a shape callers can read
  3. No else branch survives+20Where code lives
  4. The conditions are inverted, not reordered+20Where code lives
  5. The transfer is at the method’s baseline+10Where code lives

What it teaches

The rest of Code Someone Else Can Change, in C#