RemoveNumbersUsed Flashcards

1
Q

What does this line of code do and why is it used?

List<string>UserInputInRPN=ConvertToRPN(UserInput)</string>

A

Converts the expression to RPN again
re-parse the user’s input so we can identify the exact numeric tokens used.

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

How are numbers removed from the numbersAllowed if its valid and present in numbersAllowed?

A

For each numeric item, if it’s valid and is present in NumbersAllowed, remove it once.
This simulates that the user “spent” those numbers, so they’re no longer available.

foreach (string Item in UserInputInRPN)
{
if (CheckValidNumber(Item, MaxNumber))
{
if (NumbersAllowed.Contains(Convert.ToInt32(Item)))
{
NumbersAllowed.Remove(Convert.ToInt32(Item));
}

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

Why is this function important in the program?

A

Prevents the user from repeatedly using the same digit if only limited copies are available.

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

what is the point of this function?

A

Re-convert to RPN: We do it again to identify each numeric token precisely.

Check if valid: CheckValidNumber ensures it’s an integer string within range.

Remove: If the integer is in NumbersAllowed, remove one instance.

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