Skip to main content

Practice ยท 2 of 4

Diagnose the off-by-one

CHALLENGE
Difficulty: beginner+25 XP

Implement static int SumRange(int inclusive, int exclusive) (sum of inclusive..exclusive-1; empty range โ†’ 0) and static int Clamp(int value, int min, int max) (value pinned into [min, max]; ArgumentException when min > max). Both contracts are boundary-sensitive by design.

Back to lesson: Practice: Debugging workout