initial commit
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
using System.Linq;
|
||||
|
||||
namespace magicSeries
|
||||
{
|
||||
public class Series
|
||||
{
|
||||
public readonly int[] Values;
|
||||
|
||||
public readonly int[] Occurrances;
|
||||
|
||||
public int Size { get { return Values.Length; } }
|
||||
|
||||
public Series(int size)
|
||||
{
|
||||
Values = new int[size];
|
||||
Occurrances = new int[size + 1];
|
||||
Occurrances[0] = size;
|
||||
}
|
||||
|
||||
public int GetOccurrances(int i)
|
||||
{
|
||||
return Occurrances[i];
|
||||
}
|
||||
|
||||
public bool IsFeasible()
|
||||
{
|
||||
for (var n = 0; n < Values.Count(); n++)
|
||||
if (Values[n] != Occurrances[n])
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void UpdateValue(int n, int newValue)
|
||||
{
|
||||
Occurrances[Values[n]]--;
|
||||
Occurrances[newValue]++;
|
||||
Values[n] = newValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user