HomeChallengesRepsProblemsLeaderboardTake a challenge

Cheapest channel

Given the registered payment channels, return the cheapest one that can take the amount: the first one on a tie, and null when none can.

Intermediate15 min on the clock5 graded checks · 100 pointsDesigning an Object ModelPro

AssumesThe wrong containerThis stage uses a List as the vehicle, not the lesson. Choosing the right collection is taught there.

Graded by reading your code against the checklist below.

What you build

  • Write PickCheapest(IReadOnlyList<PaymentChannel> channels, decimal amount)
  • Loop with foreach, skipping channels whose limit is below the amount
  • Keep the first channel on a tie, and return null when none fits
  • Hold the registered channels in a List<PaymentChannel>
  • Trace two amounts into Answers.cs

Done means

A foreach over the base type with no type checks, decimal money, limits as conditions, and both amounts traced.

How it is graded

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

  1. Both amounts traced, including none+30Let the object answer
  2. foreach over a List<PaymentChannel>+15Choosing the right collection
  3. No type checks+20Let the object answer
  4. decimal throughout, never double+20Everything is a number underneath
  5. Over-limit channels are skipped, not caught+15Error handling

What it teaches

The rest of Designing an Object Model