CheckNumbersUsedAreAllInNumbersAllowed Flashcards

1
Q

Why is a Temp list created to check whether the numbers used are in numbersAllowed?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How are the numbers used in the RPN expression verified or rejected?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Why is this function used ?

A

Used in PlayGame to confirm the user’s expression is not using “forbidden” or “unavailable” numbers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly