Skip to main content

Practice ยท 3 of 3

Debug: The Report That Reads the File Twice

CHALLENGE
Difficulty: intermediate+25 XP

The reference implementation builds a lazy query over a counting source, checks it with Any(), then iterates it again for the report โ€” the source is read twice. Fix Run() so the source is read exactly once while behavior stays identical. ``csharp public sealed class CountingSource : IEnumerable<int> { public CountingSource(params int[] items); public int ReadCount { get; } // items actually pulled } static string Run(IEnumerable<int> source); // returns "count=<n>;max=<m>" ``

Back to lesson: Practice: LINQ Practice: Sales Analytics