diff --git a/Lottery/Generator.cs b/Lottery/Generator.cs index fcd57bf..096903a 100644 --- a/Lottery/Generator.cs +++ b/Lottery/Generator.cs @@ -5,21 +5,20 @@ /// /// Simple algorithm for generating a list of unique numbers of Limits.Count size /// - /// Defines the amount of numbers to generate, the max and min values - /// The list of numbers is returned sorted in ascending order. - public static List Generate(Limits Limits) + /// Defines the amount of numbers to generate, the min and max values + /// Numbers are returned as a sorted set. + public static SortedSet Generate(Limits limits) { - List Candidates = Enumerable.Range(Limits.Lower, Limits.Upper).ToList(); - List Numbers = []; + List candidates = Enumerable.Range(limits.Lower, limits.Upper).ToList(); + SortedSet numbers = []; - for (int i = 0; i < Limits.Count; i++) + for (int i = 0; i < limits.Count; i++) { - int RandomIndex = Random.Shared.Next(Candidates.Count); - Numbers.Add(Candidates[RandomIndex]); - Candidates.RemoveAt(RandomIndex); + int RandomIndex = Random.Shared.Next(candidates.Count); + numbers.Add(candidates[RandomIndex]); + candidates.RemoveAt(RandomIndex); } - Numbers.Sort(); - return Numbers; + return numbers; } } }