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>
|
/// <summary>
|
||||||
/// Simple algorithm for generating a list of unique numbers of Limits.Count size
|
/// Simple algorithm for generating a list of unique numbers of Limits.Count size
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="Limits">Defines the amount of numbers to generate, the max and min values</param>
|
/// <param name="limits">Defines the amount of numbers to generate, the min and max values</param>
|
||||||
/// <returns>The list of numbers is returned sorted in ascending order.</returns>
|
/// <returns>Numbers are returned as a sorted set.</returns>
|
||||||
public static List<int> Generate(Limits Limits)
|
public static SortedSet<int> Generate(Limits limits)
|
||||||
{
|
{
|
||||||
List<int> Candidates = Enumerable.Range(Limits.Lower, Limits.Upper).ToList();
|
List<int> candidates = Enumerable.Range(limits.Lower, limits.Upper).ToList();
|
||||||
List<int> Numbers = [];
|
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);
|
int RandomIndex = Random.Shared.Next(candidates.Count);
|
||||||
Numbers.Add(Candidates[RandomIndex]);
|
numbers.Add(candidates[RandomIndex]);
|
||||||
Candidates.RemoveAt(RandomIndex);
|
candidates.RemoveAt(RandomIndex);
|
||||||
}
|
}
|
||||||
Numbers.Sort();
|
return numbers;
|
||||||
return Numbers;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user