Jump to content

A-level Computing/AQA/Paper 1/Skeleton program/2025

From Wikibooks, open books for an open world

Section C Predictions.

[edit | edit source]

Section D Predictions

[edit | edit source]

Current questions are speculation by contributors to this page.

1) Using each number more than once but no repeats within the 5 given?

C#:

C# - DM - Riddlesdown In CheckNumbersUsedAreAllInNumbersAllowed you can remove the line Temp.Remove(Convert.ToInt32(Item)) around line 150 ________________________________________________________________

static bool CheckNumbersUsedAreAllInNumbersAllowed(List<int> NumbersAllowed, List<string> UserInputInRPN, int MaxNumber)
        {
            List<int> Temp = new List<int>();
            foreach (int Item in NumbersAllowed)
            {
                Temp.Add(Item);
            }
            foreach (string Item in UserInputInRPN)
            {
                if (CheckValidNumber(Item, MaxNumber))
                {
                    if (Temp.Contains(Convert.ToInt32(Item)))
                    {
                        // CHANGE START (line removed)
                        
                        // CHANGE END
                    }
                    else
                    {
                        return false;
                    }
                }
            }
            return true;
        }

C# KN - Riddlesdown In FillNumbers in the while (NumbersAllowed < 5) loop, you should add a ChosenNumber int variable and check it’s not already in the allowed numbers so there are no duplicates (near line 370): ________________________________________________________________

static List<int> FillNumbers(List<int> NumbersAllowed, bool TrainingGame, int MaxNumber)
        {
            if (TrainingGame)
            {
                return new List<int> { 2, 3, 2, 8, 512 };
            }
            else
            {
                while (NumbersAllowed.Count < 5)
                {
                    // CHANGE START
                    int ChosenNumber = GetNumber(MaxNumber);
                    while (NumbersAllowed.Contains(ChosenNumber))
                    {
                        ChosenNumber = GetNumber(MaxNumber);
                    }

                    NumbersAllowed.Add(ChosenNumber);
                    // CHANGE END
                }
                return NumbersAllowed;
            }
        }

2) Update program so expressions with whitespace are validated

C#:

Riddlesdown - KH At the moment if you put spaces between your numbers or operators it doesn't work so you will have to fix that

Put remove spaces under user input

  static string RemoveSpaces(string UserInput)
        {
            char[] temp = new char[UserInput.Length];
            string bufferstring = "";
            bool isSpaces = true;

            

            for (int i = 0; i < UserInput.Length; i++)
            {
                temp[i] = UserInput[i];
            }

            while (isSpaces)
            {
                int spaceCounter = 0;
                for (int i = 0; i < temp.Length-1 ; i++)
                {
                    if(temp[i]==' ')
                    {   
                        
                        spaceCounter++;
                        temp = shiftChars(temp, i);
                        
                    }
                }
                if (spaceCounter == 0)
                {
                    isSpaces = false;
                }
                else
                {
                    temp[(temp.Length - 1)] = '¬';
                }
                
            }
            for (int i = 0; i < temp.Length; i++)
            {
                if(temp[i] != ' ' && temp[i] != '¬')
                {
                    bufferstring += temp[i];
                }
            }
            
            return (bufferstring);
        }
        static char[] shiftChars(char[] Input, int startInt)
        {
            for (int i = startInt; i < Input.Length; i++)
            {
                if(i != Input.Length - 1)
                {
                    Input[i] = Input[i + 1];
                }
                else
                {
                    Input[i] = ' ';
                }
            }
            return (Input);
        }

3) Add exponentials (using ^ or similar)

C#:

Riddlesdown - Unknown

static bool CheckIfUserInputValid(string UserInput)
{
    // CHANGE START
    return Regex.IsMatch(UserInput, @"^([0-9]+[\+\-\*\/\^])+[0-9]+$");
    // CHANGE END
}

Answer:


In  ConvertToRPN() add the ^ to the list of operators and give it the highest precedence

}}

Riddlesdown - Unknown 
static List<string> ConvertToRPN(string UserInput)
{
    int Position = 0;
    Dictionary<string, int> Precedence = new Dictionary<string, int>
    {
        // CHANGE START
        { "+", 2 }, { "-", 2 }, { "*", 4 }, { "/", 4 }, { "^", 5 }
        // CHANGE END
    };
    List<string> Operators = new List<string>();
In EvaluateRPN() add the check to see if the current user input contains the ^, and make it evaluate the exponential if it does
Riddlesdown - Unknown
static int EvaluateRPN(List<string> UserInputInRPN)
{
    List<string> S = new List<string>();
    while (UserInputInRPN.Count > 0)
    {
        // CHANGE START
        while (!"+-*/^".Contains(UserInputInRPN[0]))
        // CHANGE END
        {
            S.Add(UserInputInRPN[0]);
            UserInputInRPN.RemoveAt(0);
        }
        double Num2 = Convert.ToDouble(S[S.Count - 1]);
        S.RemoveAt(S.Count - 1);
        double Num1 = Convert.ToDouble(S[S.Count - 1]);
        S.RemoveAt(S.Count - 1);
        double Result = 0;
        switch (UserInputInRPN[0])
        {
            case "+":
                Result = Num1 + Num2;
                break;
            case "-":
                Result = Num1 - Num2;
                break;
            case "*":
                Result = Num1 * Num2;
                break;
            case "/":
                Result = Num1 / Num2;
                break;
            // CHANGE START
            case "^":
                Result = Math.Pow(Num1, Num2);
                break;
            // CHANGE END
        }
        UserInputInRPN.RemoveAt(0);
        S.Add(Convert.ToString(Result));
    }

4) Allow the user to include brackets for their own order of operations.

5)Implement a Postfix game mode which takes the user's input in RPN instead of infix.

6) Do not advance the target list forward for invalid entries, instead inform the user the entry was invalid and prompt them for a new one.

7) Implement a menu where the user can start a new game or quit their current game.

8) The program does not end even when 'Game Over' message is displayed. Ensure the program ends when the game is over.

9) Program does not stop after 'Game Over!' with no way for the user to exit.

10) Practice game - only generates 119 as new targets.

11) Give the user a single-use ability to generate a new set of allowable numbers

12) Allow the user to input and work with negative numbers

13) Allow the user to quit the game.

14) Increase the score with a bonus equal to the quantity of allowable numbers used in a qualifying expression.

15) Implement a multiplicative score bonus for each priority (first number in the target list) number completed sequentially.

16) If the user creates a qualifying expression which uses all the allowable numbers, grant the user a special reward ability (one use until unlocked again) to allow the user to enter any number of choice and this value will be removed from the target list.