From 9c0baaa48291c6331754e00dd67793e58aa2214d Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Sun, 29 Sep 2024 03:09:50 +0100 Subject: [PATCH] create numbers using SortedSet and return as List camelCase local variables --- Lottery/Generator.cs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) 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; } } }