mirror of
https://github.com/onyx-and-iris/Lottery.git
synced 2024-11-21 21:50:48 +00:00
create numbers using SortedSet and return as List
camelCase local variables
This commit is contained in:
parent
8224684ddc
commit
9c0baaa482
@ -5,21 +5,20 @@
|
||||
/// <summary>
|
||||
/// Simple algorithm for generating a list of unique numbers of Limits.Count size
|
||||
/// </summary>
|
||||
/// <param name="Limits">Defines the amount of numbers to generate, the max and min values</param>
|
||||
/// <returns>The list of numbers is returned sorted in ascending order.</returns>
|
||||
public static List<int> Generate(Limits Limits)
|
||||
/// <param name="limits">Defines the amount of numbers to generate, the min and max values</param>
|
||||
/// <returns>Numbers are returned as a sorted set.</returns>
|
||||
public static SortedSet<int> Generate(Limits limits)
|
||||
{
|
||||
List<int> Candidates = Enumerable.Range(Limits.Lower, Limits.Upper).ToList();
|
||||
List<int> Numbers = [];
|
||||
List<int> candidates = Enumerable.Range(limits.Lower, limits.Upper).ToList();
|
||||
SortedSet<int> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user