CheckNumbersUsedAreAllInNumbersAllowed Flashcards
Why is a Temp list created to check whether the numbers used are in numbersAllowed?
We don’t want to mutate the actual NumbersAllowed just for checking, so we clone it to Temp.
List<int> Temp = new List<int>();</int></int>
How are the numbers used in the RPN expression verified or rejected?
If every numeric token in the RPN expression is found in the temporary list, we remove it.
if (CheckValidNumber(Item, MaxNumber))
if (Temp.Contains(Convert.ToInt32(Item)))
{
Temp.Remove(Convert.ToInt32(Item));
}
// returns true
If we ever fail to find a number, the method returns false.
Why is this function used ?
Used in PlayGame to confirm the user’s expression is not using “forbidden” or “unavailable” numbers.