Triple X - Taming rand()

Enjoyed this exercise, it’s a great introduction to C++

My screen output:

                    PORTAL X

                  .,-:;//;:=,
             . :H@@@MM@M#H/.,+%;,
           ,/X+ +M@@M@MM%=,-%HMMM@X/,
         -+@MM; $M@@MH+-,;XMMMM@MMMM@+-
        ;@M@@M- XM@X;. -+XXXXXHHH@M@M#@/.
      ,%MM@@MH ,@%=            .---=-=:=,.
      =@#@@@MX .,              -%HX$$%%%+;
     =-./@M@M$                  .;@MMMM@MM:
     X@/ -$MM/                    .+MM@@@M$
    ,@M@H: :@:                    . =X#@@@@-
    ,@@@MMX, .                    /H- ;@M@M=
    .H@@@@M@+,                    %MM+..%#$.
     /MMMM@MMH/.                  XM@MH; =;
      /%+%$XHH@$=              , .H@@@@MX,
       .=--------.           -%H.,@@@@@MX,
       .%MM@@@HHHXX$$$%+- .:$MMX =M@@MM%.
         =XMMM@MM@MM#H;,-+HMM@M+ /MMMX=
           =%@M@M#@$-.=$@MM@@@M; %M%=
             ,:+$+-,/H#MMMMMMM@= =,
                   =++%%%%+/:-.

You have been teleported through 5 rooms with seemingly
no way out other than back through the portals themselves.
The portal devices have deactivated but each appear to have
a numeric keypad requiring a numeric input to activate them.

Using your technology to aid you make your way back through
the portals. Note: The numbers will get harder to crack with
each portal!

Number of portals remaining: 5

Your concealed hacking tool reveals portal 5 requires three key
numbers to be entered in any order, along with the following
information:

The numbers add up to: 3
The numbers multiply to give: 1

Enter the correct 3 numbers (in any order) to escape back
through portal 5 (leave a space between each number) …
1 1 1

The portal flashes briefly then bursts into life. You get to
step through the portal :slight_smile:

Press Enter key to continue

Number of portals remaining: 4

Your concealed hacking tool reveals portal 4 requires three key
numbers to be entered in any order, along with the following
information:

The numbers add up to: 7
The numbers multiply to give: 12

Enter the correct 3 numbers (in any order) to escape back
through portal 4 (leave a space between each number) …
2 2 3

The portal flashes briefly then bursts into life. You get to
step through the portal :slight_smile:

Press Enter key to continue

Number of portals remaining: 3

Your concealed hacking tool reveals portal 3 requires three key
numbers to be entered in any order, along with the following
information:

The numbers add up to: 12
The numbers multiply to give: 60

Enter the correct 3 numbers (in any order) to escape back
through portal 3 (leave a space between each number) …
3 4 5

The portal flashes briefly then bursts into life. You get to
step through the portal :slight_smile:

Press Enter key to continue

Number of portals remaining: 2

Your concealed hacking tool reveals portal 2 requires three key
numbers to be entered in any order, along with the following
information:

The numbers add up to: 19
The numbers multiply to give: 245

Enter the correct 3 numbers (in any order) to escape back
through portal 2 (leave a space between each number) …
5 7 7

The portal flashes briefly then bursts into life. You get to
step through the portal :slight_smile:

Press Enter key to continue

Number of portals remaining: 1

Your concealed hacking tool reveals portal 1 requires three key
numbers to be entered in any order, along with the following
information:

The numbers add up to: 20
The numbers multiply to give: 270

Enter the correct 3 numbers (in any order) to escape back
through portal 1 (leave a space between each number) …
5 6 9

The portal flashes briefly then bursts into life. You get to
step through the portal :slight_smile:

Press Enter key to continue

You stumble out of the final portal back into the room you
started from. Congratulations!!!

Press Enter key to exit program

and my code:

// Portal X game (based on TripleX) to demonstrate some fundamentals of a simple C++ program

// Preprocessor Directives - instructions to the compiler
#include <iostream> // header file for input output stream functionality
#include <ctime>	// header file for time functionality

// Our PrintIntroduction function
void PrintIntroduction(int NumOfPortals)
{
	std::cout << "	                PORTAL X\n\n";
	std::cout << "	              .,-:;//;:=,               \n";
	std::cout << "	         . :H@@@MM@M#H/.,+%;,           \n";
	std::cout << "	       ,/X+ +M@@M@MM%=,-%HMMM@X/,       \n";
	std::cout << "	     -+@MM; $M@@MH+-,;XMMMM@MMMM@+-     \n";
	std::cout << "	    ;@M@@M- XM@X;. -+XXXXXHHH@M@M#@/.   \n";
	std::cout << "	  ,%MM@@MH ,@%=            .---=-=:=,.  \n";
	std::cout << "	  =@#@@@MX .,              -%HX$$%%%+;  \n";
	std::cout << "	 =-./@M@M$                  .;@MMMM@MM: \n";
	std::cout << "	 X@/ -$MM/                    .+MM@@@M$ \n";
	std::cout << "	,@M@H: :@:                    . =X#@@@@-\n";
	std::cout << "	,@@@MMX, .                    /H- ;@M@M=\n";
	std::cout << "	.H@@@@M@+,                    %MM+..%#$.\n";
	std::cout << "	 /MMMM@MMH/.                  XM@MH; =; \n";
	std::cout << "	  /%+%$XHH@$=              , .H@@@@MX,  \n";
	std::cout << "	   .=--------.           -%H.,@@@@@MX,  \n";
	std::cout << "	   .%MM@@@HHHXX$$$%+- .:$MMX =M@@MM%.   \n";
	std::cout << "	     =XMMM@MM@MM#H;,-+HMM@M+ /MMMX=     \n";
	std::cout << "	       =%@M@M#@$-.=$@MM@@@M; %M%=       \n";
	std::cout << "	         ,:+$+-,/H#MMMMMMM@= =,         \n";
	std::cout << "	               =++%%%%+/:-.             \n\n";

	//std::cout << "Press Enter key to continue\n";
	//std::cin.get();

	// Expression statements
	std::cout << "You have been teleported through " << NumOfPortals << " rooms with seemingly\n";  // std is a namespace, :: is a scope operator, << is an insertion operator which inserts chrs into the output stream
	std::cout << "no way out other than back through the portals themselves.\n" ; // \n (escape sequence) starts a new line, you could have used << std::endl at the end of the line instead
	std::cout << "The portal devices have deactivated but each appear to have\n";
	std::cout << "a numeric keypad requiring a numeric input to activate them.\n\n";
	std::cout << "Using your technology to aid you make your way back through\n"; 
	std::cout << "the portals. Note: The numbers will get harder to crack with\n";
	std::cout << "each portal!\n\n";
}

// Our PlayGame function
bool PlayGame(int NumOfPortals, int CurrentPortalNum, bool bIntroDisplayed)  // void is used here as the return type as there is no return data in this function
{
	if (not bIntroDisplayed)
	{
		PrintIntroduction(NumOfPortals);
	}
		
	std::cout << "Number of portals remaining: " << CurrentPortalNum << "\n\n";

	// Used to increase difficulty as you pass through portals
	int Difficulty = NumOfPortals - CurrentPortalNum + 1;

	// Variable declarations - Note the naming convention used by Unreal Engine (UpperCase letter for each word with no underscores)
	const int NumA = ((rand() % Difficulty) + 1) + Difficulty - 1;  // Initialised to a pseudo random number, Const ensures that the variable cannot be changed after it's been declared and initialised
	const int NumB = ((rand() % Difficulty) + 1) + Difficulty - 1;  // Initialised to a pseudo random number
	const int NumC = ((rand() % Difficulty) + 1) + Difficulty - 1;  // Initialised to a pseudo random number

	const int NumSum = NumA + NumB + NumC;  // Use of the arithmetic operator +
	const int NumProduct = NumA * NumB * NumC;

	// Expression statements
	std::cout << "Your concealed hacking tool reveals portal " << CurrentPortalNum << " requires three key\n";
	std::cout << "numbers to be entered in any order, along with the following\n";
	std::cout << "information:\n\n";
	std::cout << "The numbers add up to: " << NumSum << "\n";
	std::cout << "The numbers multiply to give: " << NumProduct << "\n\n";
	std::cout << "Enter the correct 3 numbers (in any order) to escape back\n";
	std::cout << "through portal " << CurrentPortalNum << " (leave a space between each number) ...\n";

	int GuessA;
	int GuessB;
	int GuessC;
	int GuessSum;
	int GuessProduct;

	// Get player input
	std::cin >> GuessA >> GuessB >> GuessC;  // cin captures player kbd input, >> << is an extraction operator which extracts chrs from the input stream 

	GuessSum = GuessA + GuessB + GuessC;
	GuessProduct = GuessA * GuessB * GuessC;

	if (GuessSum == NumSum && GuessProduct == NumProduct)  //  == is the equality operator (comparison operator), && is the boolean AND operator
	{
		std::cout << "\nThe portal flashes briefly then bursts into life. You get to\n";
		std::cout << "step through the portal :-)\n\n";
		return true;
	}
	else
	{
		std::cout << "\nThe portal remains lifeless.  Looks like you need to try \n";
		std::cout << "again.\n\n";
		return false;
	}
}


// main function
int main() 
{ 
	int NumOfPortals = 5;
	int CurrentPortalNum = NumOfPortals;
	bool bIntroDisplayed = false;

	srand(time(NULL));

	// Loop game until all levels completed
	while (CurrentPortalNum > 0)
	{
		bool bLevelComplete = PlayGame(NumOfPortals, CurrentPortalNum, bIntroDisplayed);  // Unreal naming convention has bool variables prefixed with a lower base b

		bIntroDisplayed = true;

		std::cin.clear();  // Clears the error status flags
		std::cin.ignore(256, '\n'); // removes all characters in the stream buffer up to the new line 256, '\n'

		std::cout << "Press Enter key to continue\n";
		std::cin.get();

		if (bLevelComplete)
		{
			--CurrentPortalNum;
		}
	}
	
	std::cout << "You stumble out of the final portal back into the room you\n";
	std::cout << "started from.  Congratulations!!!\n\n";
	
	std::cout << "Press Enter key to exit program\n";
	std::cin.get();
	
	// Return statement
	return 0; 
}

Took a while but really happy with what I made! I found it got challenging at Level 3, and really challenging by Level 4. I’m thinking of expanding this to 10 levels to spread out the difficulty, but happy with the game I’ve made!

#include <iostream>
#include <ctime>

void PrintIntroduction(int Difficulty)
{
      // Prints welcome message to the terminal
   std::cout << "Level " << Difficulty << "\n\n";
   std::cout << "There's a Pokemon GO Legendary raid happening and you and your friend were the first ones there.\n";
   std::cout << "They try and open their phone but can't remember their password. This could be a potential Shiny Rayquaza, their favourite pokemon!\n";
   std::cout << "You need to help them log into their phones and find their 3 digit pin. Good luck...\n\n";
}

bool PlayGame(int Difficulty)
{
   PrintIntroduction(Difficulty);

   // Declare 3 number code
   const int CodeA = rand() % Difficulty + Difficulty;
   const int CodeB = rand() % Difficulty + Difficulty;
   const int CodeC = rand() % Difficulty + Difficulty;

   const int CodeSum = CodeA + CodeB + CodeC;
   const int CodeProduct = CodeA * CodeB * CodeC;
   
   // Print CodeSum and CodeProduct to the terminal
   std::cout << "- There are 3 numbers in this pin";
   std::cout << "\n- The pin numbers add up to: " << CodeSum;
   std::cout << "\n- The pin numbers multiply to give: " << CodeProduct << std::endl;

   // Store Player Guess
   int GuessA, GuessB, GuessC;
   std::cin >> GuessA >> GuessB >> GuessC;
   
   int GuessSum = GuessA + GuessB + GuessC;
   int GuessProduct = GuessA * GuessB * GuessC;

   // Check if the Player's Guess is correct
  if (GuessSum == CodeSum && GuessProduct == CodeProduct)
  {
     std::cout << "\nCongrats on getting their PIN number! However your friend remembers they had 5 pin numbers on different devices, and one of these works on this phone. Take another shot at it!\n\n";
     return true;
  }
  else
  {
     std::cout << "\n That wasn't the right pin. Try again and remember, the clock's ticking for the raid!\n\n";
     return false;
  }
}

int main()
{
   srand(time(NULL)); // create new random sequence based on time of day. This way the game shuffles each time rather than being the same every time you replay.
   
   int LevelDifficulty = 1;
   int const MaxDifficulty = 5;

   while (LevelDifficulty <= MaxDifficulty) // Loop the game until all levels are completed
   {
      bool bLevelComplete = PlayGame(LevelDifficulty);
      std::cin.clear(); // Cleans any Errors
      std::cin.ignore(); // Discards the buffer

      if (bLevelComplete)
      {
         ++LevelDifficulty;
      }
      
      
   }
   
   std::cout << "Congratulations! You figured out their pin number in time for the Legendary raid! And ooh, is that a shiny I see?\n";

   return 0; 
}
/**
 * preprocessor directive
*/
#include <iostream>
#include <ctime>

/**
 * Functions here
*/

/**
 * @author          Simarpreet Singh Aneja <er.simar.aneja@gmail.com>
 * @function        PrintIntroduction       
 * @return          void
 * @param           none
 */

void PrintIntroduction(int LevelDifficulty) {
//namespace::functionname (:: = scope operator)(cout is defined in cout namespace)
    std::cout << "\n\nYou are a secret agent breaking into a level " << LevelDifficulty;
    std::cout << " secure server room...\nYou need to enter the correct codes to continue...\n\n";
    std::cout << " >>>>>-----------------------> \n";
}
/**
 * @author          Simarpreet Singh Aneja <er.simar.aneja@gmail.com>
 * @function        PlayGame       
 * @return          boolean
 * @param           none
 */

bool PlayGame(int DifficultyLevel) {

    PrintIntroduction(DifficultyLevel);
    // Declare variables
    const int CodeA = (rand() % DifficultyLevel) + DifficultyLevel;
    const int CodeB = (rand() % DifficultyLevel) + DifficultyLevel;
    const int CodeC = (rand() % DifficultyLevel) + DifficultyLevel;

    const int CodeSum = CodeA + CodeB + CodeC;
    const int CodeProduct = CodeA * CodeB * CodeC;

    // Print sum and product to the terminal
    std::cout << std::endl;
    std::cout << " + There are three numbers in the code";
    std::cout << "\n + The codes add-up to : " << CodeSum ;
    std::cout << "\n + The codes multiply to give : " << CodeProduct << std::endl;

    int GuessA,GuessB,GuessC;

    //chracter input  >>(extraction operator) //takes input till first space
    std::cin >> GuessA >> GuessB >> GuessC;
    std::cout << "You entered : " << GuessA << GuessB << GuessC << std::endl;
    
    int GuessSum = GuessA + GuessB + GuessC;
    int GuessProduct = GuessA * GuessB * GuessC;

    if(GuessSum == CodeSum && GuessProduct == CodeProduct) {
        std::cout << "\n Well Done Agent!! You have extracted the file successfully !! Keep going O='`o ";
        return true;
    }
    else {
        std::cout << "\n You entered wrong code Agent !! TRY AGAIN {-_-} \n";
        return false;
    }
}



/**
 * @author          Simarpreet Singh Aneja <er.simar.aneja@gmail.com>
 * @function        main       
 * @return          0
 * @param           none
 */

int main() 
{
    srand(time(NULL)); // NOTE seeds the rand function using srand... creates the random number based on time of day
    int LevelDifficulty = 1;
    const int MaxDifficulty = 5;

    while (LevelDifficulty <= MaxDifficulty) //loop the game until all the levels unlocked
    {
        try {
            bool bLevelComplete; 
            bLevelComplete = PlayGame(LevelDifficulty);
        
            // NOTE As cin takes the number and if someone enter the character, it become uncontrollable and we need to reset the cin stream
            // todo that we need to clear the stream and also ignore the chracters by doing below calls 

            std::cin.clear();
            std::cin.ignore(); 

            if (bLevelComplete)
            {
                // increase the level difficulty
                LevelDifficulty += 1;
            }
        }
        catch(const std::exception& e) {
            std::cerr << e.what() << '\n';
            std::cin.clear();
        }
        catch(...) {
            std::cerr << "UNKNOWN ERROR" << '\n';
            std::cin.clear();
        }
    }

    std::cout << "CONGRATS AGENT !! ALL LEVELS UNLOCKED !! GET OUT OF ROOM !!\n";
  
    return 0;
}```

Here’s my submission for the Triple X game.
I could never get the ASCII art to work because it kept registering every “” as an attempted escape command. I really didn’t put much effort into the story either lol. But I had a lot of fun putting it all together, and even added a game over screen and a feature to restart the game if you win or lose!

#include
#include

void PlayIntro(int Difficulty)
{
//Intro Text
std::cout <<std::endl;
std::cout << "You are being chased by a raging pack of " << Difficulty << “00 hungry lions.\n\n”;
std::cout << “The only way to escape is to input a series of codes!\n\n”;
}

bool PlayGame(int Difficulty)
{
PlayIntro(Difficulty);
//Assign Variables Here

    const int CodeA = rand() % Difficulty + 1;
    const int CodeB = rand() % Difficulty + 1;
    const int CodeC = rand() % Difficulty + 1;

    const int CodeSum = CodeA + CodeB + CodeC;
    const int CodeProd = CodeA * CodeB * CodeC;

    //Hints Text
    std::cout << "Your Psychic Powers tell you...\n";
    std::cout << "- There are three numbers in the code";
    std::cout << "\n- The three numbers in the code add up to: " << CodeSum;
    std::cout << "\n- The three numbers multiply together to make: " << CodeProd;
    std::cout <<std::endl;

    //Player Input Variables
    int GuessA, GuessB, GuessC;
    std::cin >> GuessA >> GuessB >> GuessC;
    int GuessSum = GuessA + GuessB + GuessC;
    int GuessProd = GuessA * GuessB * GuessC;
    std::cout <<std::endl;

   //Win/Lose Conditions
    if(GuessSum == CodeSum && GuessProd == CodeProd)
    {
        std::cout << "You did it! You're close, but the pack has grown in size!\n";
        return true;
    }

    else
    {
    std::cout << "Yikes! That wasn't right!\n";
    std::cout << "\nYour numbers add up to: " <<GuessSum;
    std::cout << "\nYour numbers multiply to: " <<GuessProd;
    std::cout <<std::endl;
    std::cout << "\nThe pack grows closer...\n";
    return false;
    }
    }

int main()
{
srand(time(NULL));
int StartLives = 4;
int Lives = StartLives;
int StartDifficulty = 1;
int LevelDifficulty = StartDifficulty;
const int MaxLevel = 5;
while (LevelDifficulty <= MaxLevel)
{
bool bLevelComplete = PlayGame(LevelDifficulty);
std::cin.clear();
std::cin.ignore();

    if (bLevelComplete)
     {
        ++LevelDifficulty;
     }

//Lose Output
    if (!bLevelComplete)
     {
        
        -- Lives;
        std::cout << "The pack is now " << Lives <<" yards away from you!\n";
     
     
//Game Over
    if (Lives == 0)
        {
           std::cout << "\nOh dear. Looks like you were eaten by the pack of hungry lions! Try again?\n";
           std::cout << "yes = 1      no = 0\n";
           int TryAgain;
           std::cin >> TryAgain;
           if (TryAgain == 1)
           {
               Lives = StartLives;
               LevelDifficulty = StartDifficulty;
              int main() ;
           }
           if (TryAgain == 0)
            {
           return 0;
            }
        }
     }
    if (LevelDifficulty > MaxLevel)
    {
     std::cout << "\nYou escaped the hungry lions! Great job!";
     std::cout << "\nPlay again?\n";
     std::cout << "yes = 1      no = 0\n";
     int TryAgain;
           std::cin >> TryAgain;
           if (TryAgain == 1)
           {
               Lives = StartLives;
               LevelDifficulty = StartDifficulty;
              int main() ;
           }
           if (TryAgain == 0)
            {
           return 0;
            }
    }
    }
     

}
#include <iostream>
#include <ctime>

void PrintIntroduction(int Difficulty)
{
    // Print welcome messages to the terminal
    std::cout << R"(
______________ ___ ._________________________
\__    ___/   |   \|   \_   _____/\_   _____/
   |   | /    ~    \   ||    __)_  |    __)  
   |   | \    Y    /   ||        \ |     \   
   |___|  \___|_  /|___/_______  / \___  /   
                \/             \/      \/    
        )" ; 
    std::cout << "\nYou are a burglar trying to get into a house by hacking a level " << Difficulty; 
    std::cout << " alarm system...\nYou need to enter the correct codes to continue...\n\n";
}

bool PlayGame(int Difficulty)
{
PrintIntroduction(Difficulty);

    const int CodeA = rand() % Difficulty + Difficulty;
    const int CodeB = rand() % Difficulty + Difficulty;
    const int CodeC = rand() % Difficulty + Difficulty;

    const int CodeSum = CodeA + CodeB + CodeC;
    const int CodeProduct = CodeA * CodeB * CodeC;

    // Print sum and product to the terminal
    std::cout << "> There are 3 numbers in the code";
    std::cout << "\n> The codes add-up to: " << CodeSum;
    std::cout << "\n> The codes multiply to give: " << CodeProduct << std::endl;

    // Store player guess
    int GuessA, GuessB, GuessC;
    std::cin >> GuessA >> GuessB >> GuessC;

    int GuessSum = GuessA + GuessB + GuessC;
    int GuessProduct = GuessA * GuessB * GuessC;

    // Check if the players guess is correct
if (GuessSum == CodeSum && GuessProduct == CodeProduct) 
    {   
    std::cout << "\nYou succeded breakin into a level " << Difficulty << " alarm system! Keep going!";
    return true;
    }
else
    {
    std::cout << "\nYou failed to break into a level " << Difficulty << " alarm system! Try again!";
    return false;
    }
}

int main() 
{
srand(time(NULL)); // create new random sequance based on time of day
int LevelDifficulty = 1;
int const MaxLevel = 5;

while (LevelDifficulty <= MaxLevel) // Loop game until all levels are completed
    {
    bool bLevelComplete = PlayGame(LevelDifficulty);
    std::cin.clear(); //Clears any errors
    std::cin.ignore(); //Discards the buffer 

    if (bLevelComplete)
    {
        ++LevelDifficulty;
    }
     
    }

std::cout << "\n\nGG, you finished the game!\n";

return 0;        
}
#include <iostream>
#include <ctime>

void Monitor()
{
    std::cout << "\n\n ___________________________________________________________  \n";
    std::cout << "/  ________________________________________________________ \\ \n";
    std::cout << "| /                                                        \\ |\n";
    std::cout << "| |                                                        | |\n";
    std::cout << "| |                                                        | |\n";
    std::cout << "| |              WELCOME, MOST WANTED CRIMINAL             | |\n";
    std::cout << "| |                  ___________________                   | |\n";
    std::cout << "| |                 |___________________|                  | |\n";
    std::cout << "| |                                                        | |\n";
    std::cout << "| |                                                        | |\n";
    std::cout << "| \\________________________________________________________| |\n";
    std::cout << "\\____________________________________________________________/\n";
    std::cout << "\nYou are a death row prisoner working with the government for freedom\n";
    std::cout << "Your goal is to crack the secret codes from the most wanted criminal's computer\n";
}

void PrintIntroduction(int Difficulty)
{
    //Prints out intro
    std::cout << "You have guessed " << Difficulty; std::cout << " character(s) so far...\n";

}

bool PlayGame(int Difficulty)
{
    PrintIntroduction(Difficulty);
    //Values
    const int CodeA = rand() % Difficulty + Difficulty;
    const int CodeB = rand() % Difficulty + Difficulty;
    const int CodeC = rand() % Difficulty + Difficulty;

    const int CodeSum = CodeA + CodeB + CodeC;
    const int CodeProduct = CodeA * CodeB * CodeC;

    //Prints out numbers from variables above
    std::cout << "! There are 3 numbers used as the password on the computer\n";
    std::cout << "! The password adds up to " << CodeSum;
    std::cout << "\n! The password multiply to give " << CodeProduct << std::endl;

    //Stores guesses
    int GuessA, GuessB, GuessC;
    std::cin >> GuessA >> GuessB >> GuessC;

    int GuessSum = GuessA + GuessB + GuessC;
    int GuessProduct = GuessA * GuessB * GuessC;

    //Win or Lose
    if (GuessSum == CodeSum && GuessProduct == CodeProduct)
    {
        std::cout << "\n  You guessed one character!  \n";
        return true;
    }
    else
    {
        std::cout << "\n  INCORRECT PASSWORD. Try again.  \n";
        return false;
    }
    //End
}

int main()
{
    srand(time(NULL)); //Seed

    int LevelDifficulty = 1; //Difficulty
    const int MaxDifficulty = 9; //Max Difficulty
    //Where the game runs
    Monitor();
    while (LevelDifficulty <= MaxDifficulty)
    {
        bool bLevelComplete = PlayGame(LevelDifficulty);
        std::cin.clear(); // Clears any errors
        std::cin.ignore(); // Discards the buffer

        if (bLevelComplete)
        {
            ++LevelDifficulty;
        }
        
    }
    //Winrar
    std::cout << "Congratulations!\nYou have fully cracked the password. The criminal has been located and arrested.\n";
    std::cout << "The police has thanked you for your hard work and rewarded you with freedom.";
    return 0;
}

So far Bigbos wall have progressed to increase in difficulty with level providing a winning message once the player completed all ten levels. So far I have progressed to level 5 while playing from thereon the game becomes really hard at least for me.

#include <iostream>
#include <ctime>

void PrintIntroduction(int Difficulty)
{
    std::cout << "\n\n         +---+         +---+\n";
    std::cout << "        +-----+       +-----+\n";
    std::cout << "       +-------+     +-------+\n";
    std::cout << "       +--------+   +--------+\n";
    std::cout << "        +-------------------+\n";
    std::cout << "        +---+  +-----+  +---+\n";
    std::cout << "       +----+  +-----+  +----+\n";
    std::cout << "       +---------------------+\n";
    std::cout << "        +-------------------+\n";
    std::cout << "     +   +-------+  +------+   +\n";
    std::cout << "     +-+  +---------------+  +-+\n";
    std::cout << "     +--+  +-------------+  +--+\n";
    std::cout << "     +---------+      +--------+\n";
    std::cout << "     +-------------------------+\n";
    std::cout << "     +----------+   +----------+\n";
    std::cout << "     +-------------------------+\n";
    std::cout << "     +--------+       +--------+\n";
    std::cout << "     +-----+             +-----+\n";
    std::cout << "     +---+                 +---+\n";
    std::cout << "     +--+                   +--+\n";
    std::cout << "     +-+                     +-+\n";
    std::cout << "     +                         +\n";

 //Introduction, telling about the situation and giving the user an idea of what is going on and what is expected from them
    std::cout << "\nBigbo the talking bear is about to arrange boulders into a wall on the eastern border of the forest.\n";
    std::cout << "This way he can ensure that the honey bears is not breaking in and stealing honey on his territory.\n";
    std::cout << "But the wall is not yet finished and there are still three large holes in the wall.\n";  
    std::cout << "Bigbos wall have currently progressed to level: "<<Difficulty;
}

bool PlayGame(int Difficulty)
{
    PrintIntroduction(Difficulty);
    //generate a random number based on the level difficulty offset by itself this way no zeros get included and the games difficulty increases more at each level
    const int BouldersA = rand()%Difficulty+Difficulty;
    const int BouldersB = rand()%Difficulty+Difficulty;
    const int BouldersC = rand()%Difficulty+Difficulty;

    const int BoulderSum = BouldersA + BouldersB + BouldersC;
    const int BoulderProduct = (BouldersA*BouldersB)*BouldersC;

    //print out instructions to user
    std::cout << "\n\nA number of boulders are missing at each of the holes\n";   
    std::cout << "+ Togheter they add up to: "<<BoulderSum;
    std::cout << "\n+ The boulders missing at each hole multiplies to give: "<<BoulderProduct; 
    std::cout << "\n Can you help Bigbo figure out how many boulders he needs to fill each of the holes?\n"; 
    
    //store player guess
    int GuessA, GuessB, GuessC;
    std::cin >> GuessA >> GuessB >> GuessC;
    

    int GuessSum = GuessA + GuessB + GuessC;
    int GuessProduct = (GuessA*GuessB)*GuessC; 
    //Check if players guess is correct
    if(GuessSum == BoulderSum && GuessProduct == BoulderProduct)
    {
        std::cout << "\nGood job that was exactly the amount of boulders missing in Bigbos wall";
        return true;
    }
    else
    {
        std::cout << "\nYou gave poor Bigbo the wrong amount of boulers.\n";
        std::cout << "Now he will spend the rest of the evening figiuring out why they wont match the holes in his wall\n";
        return false;
    }
}


int main()
{
    srand(time(NULL)); // randomizes the rand seed based on the time of the day giving more random results

    int LevelDifficulty = 1;

    while (LevelDifficulty<=10)
    {      
        bool bLevelComplete = PlayGame(LevelDifficulty);
        std::cin.clear();//this clears any input errors
        std::cin.ignore();// this clears the input buffer

        if (bLevelComplete)
        {
            ++LevelDifficulty;
        }
        
    }
    std::cout << "\nCongratulations you helped bigbo completing his wall and fill all the holes with boulders.";
    std::cout << "\n Now he wont have to wonrry about the honey bears breaking into his territory anymore.";
    return 0;
}

Great little exercise to work as an intro into C++
A little ASCII art and added a 3 second timer between rounds just so that the player has a chance to appreciate their victory.
Might deveolp it further so that the ASCII art only happens in the first instance of the game but we’ll see.

#include
#include
#include <Windows.h>

using namespace std;

void PrintIntroduction(int Difficulty)
{

cout << "  TTTTTTTTTTTTTTTTTTTTTTT                     iiii                     lllllll                          XXXXXXX       XXXXXXX     \n";
cout << "  T:::::::::::::::::::::T                    i::::i                    l:::::l                          X:::::X       X:::::X     \n";
cout << "  T:::::::::::::::::::::T                     iiii                     l:::::l                          X:::::X       X:::::X     \n";
cout << "  T:::::TT:::::::TT:::::T                                              l:::::l                          X::::::X     X::::::X     \n";
cout << "  TTTTTT  T:::::T  TTTTTTrrrrr   rrrrrrrrr  iiiiiiippppp   ppppppppp    l::::l     eeeeeeeeeeee         XXX:::::X   X:::::XXX     \n";
cout << "          T:::::T        r::::rrr:::::::::r i:::::ip::::ppp:::::::::p   l::::l   ee::::::::::::ee          X:::::X X:::::X        \n";
cout << "          T:::::T        r:::::::::::::::::r i::::ip:::::::::::::::::p  l::::l  e::::::eeeee:::::ee         X:::::X:::::X         \n";
cout << "          T:::::T        rr::::::rrrrr::::::ri::::ipp::::::ppppp::::::p l::::l e::::::e     e:::::e          X:::::::::X          \n";
cout << "          T:::::T         r:::::r     r:::::ri::::i p:::::p     p:::::p l::::l e:::::::eeeee::::::e          X:::::::::X          \n";
cout << "          T:::::T         r:::::r     rrrrrrri::::i p:::::p     p:::::p l::::l e:::::::::::::::::e          X:::::X:::::X         \n";
cout << "          T:::::T         r:::::r            i::::i p:::::p     p:::::p l::::l e::::::eeeeeeeeeee          X:::::X X:::::X        \n";
cout << "          T:::::T         r:::::r            i::::i p:::::p    p::::::p l::::l e:::::::e                XXX:::::X   X:::::XXX     \n";
cout << "        TT:::::::TT       r:::::r           i::::::ip:::::ppppp:::::::pl::::::le::::::::e               X::::::X     X::::::X     \n";
cout << "        T:::::::::T       r:::::r           i::::::ip::::::::::::::::p l::::::l e::::::::eeeeeeee       X:::::X       X:::::X     \n";
cout << "        T:::::::::T       r:::::r           i::::::ip::::::::::::::pp  l::::::l  ee:::::::::::::e       X:::::X       X:::::X     \n";
cout << "        TTTTTTTTTTT       rrrrrrr           iiiiiiiip::::::pppppppp    llllllll    eeeeeeeeeeeeee       XXXXXXX       XXXXXXX     \n";
cout << "                                                    p:::::p                                                                       \n";
cout << "                                                    p:::::p                                                                       \n";
cout << "                                                   p:::::::p                                                                      \n";
cout << "                                                   p:::::::p                                                                      \n";
cout << "                                                   p:::::::p                                                                      \n";
cout << "                                                   ppppppppp                                                                      \n\n\n";
		



// Print welcome messages to the terminal
cout << "You are a secret agent breaking into a level " << Difficulty;
cout << " secure server room \nYou need to enter the correct codes to continue...\n\n";

}

bool PlayGame(int Difficulty)
{

PrintIntroduction(Difficulty);

const int CodeA = rand() % Difficulty + Difficulty;
const int CodeB = rand() % Difficulty + Difficulty;
const int CodeC = rand() % Difficulty + Difficulty;


const int CodeSum = CodeA + CodeB + CodeC;
const int CodeProduct = CodeA * CodeB * CodeC;

// Print CodeSum and CodeProduct to the terminal
cout << "There are 3 numbers in the code \n";
cout << "The codes add-up to: " << CodeSum;
cout << "\nThe 3 numbers in the code multiply together to give: " << CodeProduct << endl;

//Store player guess
int GuessA, GuessB, GuessC;
cin >> GuessA >> GuessB >> GuessC;
cout << "You entered: " << GuessA << GuessB << GuessC;

int GuessSum = GuessA + GuessB + GuessC;
int GuessProduct = GuessA * GuessB * GuessC;

//Check if the players guess is correct
if (GuessSum == CodeSum && GuessProduct == CodeProduct)
{
	cout << "\nCode accepted! Progress to deeper servers.\n";
	Sleep(3000);
	return true;
}
else
{
	cout << "\nHack attempt detected! Try again.";
	Sleep(3000);
	return false;
}

}

int main()
{
srand(time(NULL)); // create new random sequence based in time of day

int LevelDifficulty = 1;
const int MaxDifficulty = 5;

while (LevelDifficulty <= MaxDifficulty) // loop game until all levels are completed
{
	bool bLevelComplete = PlayGame(LevelDifficulty);
	cin.clear(); // Clears any errors
	cin.ignore(); // Discards the buffer

	if (bLevelComplete) 
	{
		++LevelDifficulty;
	}
}

cout << "\n All servers cracked, now get outta there.";
return 0;

}

The game started to get hard around level three. I really enjoyed this section and I came into it with no previous knowledge of coding. I learned a lot and am excited to continue the course.

Here is my Version of triplex and gets pretty around level 3

// This is my first c++ only project made during the second section of the unreal c++ udemy course
#include <iostream>
#include <ctime>

void PrintWinMessage()
{
    std::cout << R"(
_____.___.               __      __.__        
\__  |   | ____  __ __  /  \    /  \__| ____  
 /   |   |/  _ \|  |  \ \   \/\/   /  |/    \ 
 \____   (  <_> )  |  /  \        /|  |   |  \
 / ______|\____/|____/    \__/\  / |__|___|  /
 \/                            \/          \/  
)";
std::cout << "\nYOU GOT SPONGEBOB BACK";
}

void PrintIntroduction(int Difficulty)
{
 std::cout << R"(
______________
|\ ___________ /|
| |  _ _ _ _  | |
| | | | | | | | |
| | |-+-+-+-| | |
| | |-+-+-+-| | |
| | |_|_|_|_| | |
| |     ___   | |
| |    /__/   | |
| |   [%==] ()| |
| |         ||| |
| |         ()| |
| |           | |
| |           | |
| |           | |
|_|___________|_|     
)";
    
    std::cout << "\n\nSquidward: ah it sure is nice that spongebob isn't around anymore......WE GOTTA GET SPONGEBOB BACK!!!!!\n";
    std::cout << "SPONGEBOB IS JUST THROUGH THESE LEVEL " << Difficulty;
    std::cout << " DOORS WE GOTTA GUESS THE RIGHT CODES TO FIND HIM\n\n";
}

bool PlayGame(int Difficulty)
{
    // Intro messages
    PrintIntroduction(Difficulty); 

    // Set default code values
    const int CodeA = rand() % Difficulty + Difficulty;
    const int CodeB = rand() % Difficulty + Difficulty;
    const int CodeC = rand() % Difficulty + Difficulty;

    // Get the sum and product of code values
    const int CodeSum = CodeA + CodeB + CodeC; 
    const int CodeProduct = CodeA * CodeB * CodeC; 

    // Hint messages
    std::cout << std::endl;
    std::cout << "+ There are 3 numbers in the code";
    std::cout << "\n+ The codes add up to: " << CodeSum;
    std::cout << "\n+ The codes multiply to give: " << CodeProduct << std::endl;

    // Store player input
    int GuessA, GuessB, GuessC;
    std::cin >> GuessA >> GuessB >> GuessC;
   

    const int GuessSum = GuessA + GuessB + GuessC;
    const int GuessProduct = GuessA * GuessB * GuessC;

    // See if guess is right
    if (GuessSum == CodeSum && GuessProduct == CodeProduct)
    {
        std::cout << "\nON TO THE NEXT DOOR";
        return true;
    }
    else 
    {
       std::cout << "\nO MY GOSH HOW ARE THIS BAD??? LUCKILY YOU CAN TRY AGAIN!!!"; 
       return false;
    }
}

int main()
{
    srand(time(NULL));

    int LevelDifficulty = 1;
    const int MaxLevel = 4;

    while (LevelDifficulty <= MaxLevel) // loop game until all levels are completed
    {
        bool bLevelComplete = PlayGame(LevelDifficulty);
        std::cin.clear();
        std::cin.ignore();

        if (bLevelComplete)
        {
            ++LevelDifficulty;
        }
    }

    PrintWinMessage();

    return 0;
}

My code at the end:


I managed to beat the game in one try (without any wrong guesses) but the final level (level 6) was quite hard compared to the rest.


Thanks Instructor

Because I use a calculator, so I win all 5 levels of my game :slight_smile: but of course I cant win when I add more levels :slight_smile:
I added 20 levels now so basically it will get impossible :smiley:

#include <iostream>
#include <ctime>

void PrintIntroduction(int Door) {
    // In here we show some text to the terminal so player will feel the game 
    std::cout << "\n\n___________      .__       .__         ____  ___\n";
    std::cout << "\\__    ___/______|__|_____ |  |   ____ \\   \\/  /\n";
    std::cout << "  |    |  \\_  __ \\  \\____ \\|  | _/ __ \\ \\     / \n";
    std::cout << "  |    |   |  | \\/  |  |_> >  |_\\  ___/ /     \\ \n";
    std::cout << "  |____|   |__|  |__|   __/||____/\\___  >___/\\  \\\n";
    std::cout << "                    |__|   |          \\/      \\_/\n";
    std::cout << "***** Encrypted line now open *****\n";
    std::cout << "Unknown: I've reached the door number " << Door << "...\n";
}

bool PlayGame(int Door) {
    PrintIntroduction(Door);
    // Declaring 3 numbers of code
    const int CodeA = rand() % Door + Door;
    const int CodeB = rand() % Door + Door;
    const int CodeC = rand() % Door + Door;

    const int CodeSum = CodeA + CodeB + CodeC;
    const int CodeProduct = CodeA * CodeB * CodeC;
    // print CodeSum and CodeProduct to the terminal
    std::cout << "Unknown: It needs a 3 coded password, There is also a hint!\n";
    std::cout << "Unknown: It says The code adds up to " << CodeSum << " multiplies to " << CodeProduct << " can you break it?\n";

    int GuessA;
    int GuessB;
    int GuessC;
    char lastWord;

    // sTORE PLAYER GUESS
    std::cout << "You: ";
    std::cin >> GuessA >> GuessB >> GuessC;

    int GuessSum = GuessA + GuessB + GuessC;
    int GuessProduct = GuessA * GuessB * GuessC;

    std::cout << "Your Guess Sum: " << GuessSum << " Your Guess Product: " << GuessProduct << std::endl;

    // checkk if players guess is currect
    if(GuessSum == CodeSum && GuessProduct == CodeProduct) {
        std::cout << "Unknown: Great! Im in, Stay on for next\n";
        return true;
    } else {
        std::cout << "Unknown: Oh no, It turned red! Its alerting, What should I do?\n";
        std::cout << "You: ";
        std::cin >> lastWord;
        std::cout << "Unknown: Damn, Guards are here dont loose hope, you can still do this without me, Bye bye friend.\n";
        return false;
    }
    return false;
}

int main() {
    srand(time(NULL)); // creating a new random sequence based on the time of day
    int DoorNumber = 1;
    int const LastDoorNumber = 20;
    while(DoorNumber <= LastDoorNumber) { // Looop the game until all doors are opened
        bool bLevelComplete = PlayGame(DoorNumber);
        std::cin.clear(); // Clears any error
        std::cin.ignore(); // Discard the buffer

        if(bLevelComplete) {
            ++DoorNumber;
        } else {
            char YourAnswer;
            std::cout << "Unknown: Im out! Whats the next move to get you out?\n";
            std::cout << "You: ";
            std::cin >> YourAnswer;
            std::cout << "Unknown: Allright, consider it done, I keep the line on.\n";
            return 0;
        }
    }
    char YourAnswer;
    std::cout << "Unknown: Im out! Whats the next move to get you out?\n";
    std::cout << "You: ";
    std::cin >> YourAnswer;
    std::cout << "Unknown: Allright, consider it done, I keep the line on.\n";
    return 0;
}

22222222222

#include <iostream>
#include <ctime>

void Printroduction(int Difficulty){
    std::cout<<"\nWelcome to TrpleX : Number Guessing Game with C++ By Thuta\n";
    std::cout<<"\nLevel\n"<<Difficulty;
    std::cout<<"\nEnter the correct code to continue...\n";
}
bool PlayGame(int Difficulty)
{
    Printroduction(Difficulty);

    const int CodeA = rand() % Difficulty + Difficulty;
    const int CodeB = rand() % Difficulty + Difficulty;
    const int CodeC = rand() % Difficulty + Difficulty;

    const int CodeSum = CodeA + CodeB + CodeC;
    const int CodeProduct = CodeA * CodeB * CodeC;

    //print codesum and codeproduct to terminal
    std::cout << std::endl;
    std::cout << "There are 3 numbers in the code\n"; 
    std::cout << "The code add-up to " << CodeSum<<std::endl;
    std::cout << "The code multiply to " << CodeProduct<<std::endl;

    //store player guesses
    int GuessA, GuessB, GuessC;
    std::cin >> GuessA >> GuessB >> GuessC;

    //Checking the guesses
    int GuessSum = GuessA + GuessB + GuessC;
    int GuessProduct= GuessA * GuessB * GuessC;
   
    if (GuessSum == CodeSum && GuessProduct == CodeProduct) 
    {
        std::cout << "You're Right. Let's keep going to the next one!! \n";
        return true;
    } 
    else 
    {
        std::cout << "You're Wrong. Let's try that again!! \n";
        return false;
    }
}

int main()
{
    srand(time(NULL));
    int LevelDifficulty = 1;
    int const MaxLevel = 5;
    while(LevelDifficulty <= MaxLevel)
    {
    bool bLevelComplete = PlayGame(LevelDifficulty);
    std::cin.clear();
    std::cin.ignore();
    
    if(bLevelComplete)
    {
        ++LevelDifficulty;
    }
    }

    std::cout << "\nYou got it, Well Done !!\n\n";
    return 0;
}

I can’t beat level 5

#include <iostream>
#include <ctime>

int FirstCode, SecondCode, ThirdCode, CodeSum, CodeProduct, PlayerResponse1,
    PlayerResponse2, PlayerResponse3, PlayerResponseSum, PlayerResponseProduct;

void IntroduceStory()
{
    std::cout << "Entering TripleX\n";
    std::cout << "================\n";

    std::cout << "You hurry up, and move into the data center room.\n";
    std::cout << "Your heart is racing, and the adrenaline is racing through "
                 "your veins."
              << std::endl;
    std::cout << "Some of the machines in front you have USB sockets.\n";
    std::cout << "Taking out your dev machine from your backpack, it takes you"
                 " a couple of tries to plug it in; your hand is trembling "
                 "from the stress.\n";
    std::cout << "Finally, with your trusty Arch Linux OS, you're ready.\n\n";
}

void PrintValidResponseMessage(int Difficulty)
{
    if (Difficulty == 1)
    {
        std::cout << R"(
 ______________
||            ||
||            ||
||            ||
||            ||
||____________||
|______________|
 \\############\\
  \\############\\
   \      ____    \
    \_____\___\____\
)"
                  << "\n";

        std::cout << "OK, that worked. You list all volumes available.\n\n";
        return;
    }

    if (Difficulty == 2)
    {
        std::cout << R"(
Fight Bugs                      |     |
                                \\_V_//
                                \/=|=\/
                                 [=v=]
                               __\___/_____
                              /..[  _____  ]
                             /_  [ [  M /] ]
                            /../.[ [ M /@] ]
                           <-->[_[ [M /@/] ]
                          /../ [.[ [ /@/ ] ]
     _________________]\ /__/  [_[ [/@/ C] ]
    <_________________>>0---]  [=\ \@/ C / /
       ___      ___   ]/000o   /__\ \ C / /
          \    /              /....\ \_/ /
       ....\||/....           [___/=\___/
      .    .  .    .          [...] [...]
     .      ..      .         [___/ \___]
     .    0 .. 0    .         <---> <--->
  /\/\.    .  .    ./\/\      [..]   [..]
 / / / .../|  |\... \ \ \    _[__]   [__]_
/ / /       \/       \ \ \  [____>   <____]
)"
                  << "\n";

        std::cout << "Hmm, you found a bug in your script. With that fixed you break to the next layer.\n";
        return;
    }

    {
        std::cout << R"(
                    ____
                 _.' :  `._
             .-.'`.  ;   .'`.-.
    __      / : ___\ ;  /___ ; \      __
  ,'_ ""--.:__;".-.";: :".-.":__;.--"" _`,
  :' `.t""--.. '<@.`;_  ',@>` ..--""j.' `;
       `:-.._J '-.-'L__ `-- ' L_..-;'
         "-.__ ;  .-"  "-.  : __.-"
             L ' /.------.\ ' J
              "-.   "--"   .-"
             __.l"-:_JL_;-";.__
          .-j/'.;  ;""""  / .'\"-.
        .' /:`. "-.:     .-" .';  `.
     .-"  / ;  "-. "-..-" .-"  :    "-.
  .+"-.  : :      "-.__.-"      ;-._   \
  ; \  `.; ;                    : : "+. ;
  :  ;   ; ;                    : ;  : \:
 : `."-; ;  ;                  :  ;   ,/;
  ;    -: ;  :                ;  : .-"'  :
  :\     \  : ;             : \.-"      :
   ;`.    \  ; :            ;.'_..--  / ;
   :  "-.  "-:  ;          :/."      .'  :
     \       .-`.\        /t-""  ":-+.   :
      `.  .-"    `l    __/ /`. :  ; ; \  ;
        \   .-" .-"-.-"  .' .'j \  /   ;/
         \ / .-"   /.     .'.' ;_:'    ;
          :-""-.`./-.'     /    `.___.'
                \ `t  ._  /  bug :F_P:
                 "-.t-._:'
)"
                  << "\n";

        std::cout << "OK, that worked. You mount the volume to your machine, and start copying it's data.";
        return;
    }
}

void PrintInValidResponseMessage()
{
    std::cout << R"(
███████▓█████▓▓╬╬╬╬╬╬╬╬▓███▓╬╬╬╬╬╬╬▓╬╬▓█
████▓▓▓▓╬╬▓█████╬╬╬╬╬╬███▓╬╬╬╬╬╬╬╬╬╬╬╬╬█
███▓▓▓▓╬╬╬╬╬╬▓██╬╬╬╬╬╬▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
████▓▓▓╬╬╬╬╬╬╬▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
███▓█▓███████▓▓███▓╬╬╬╬╬╬▓███████▓╬╬╬╬▓█
████████████████▓█▓╬╬╬╬╬▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬█
███▓▓▓▓▓▓▓▓▓▓▓▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
████▓▓▓▓▓▓▓▓▓▓▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
███▓█▓▓▓▓▓▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
█████▓▓▓▓▓▓▓▓█▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
█████▓▓▓▓▓▓▓██▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
█████▓▓▓▓▓████▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
████▓█▓▓▓▓██▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
████▓▓███▓▓▓▓▓▓▓██▓╬╬╬╬╬╬╬╬╬╬╬╬█▓╬▓╬╬▓██
█████▓███▓▓▓▓▓▓▓▓████▓▓╬╬╬╬╬╬╬█▓╬╬╬╬╬▓██
█████▓▓█▓███▓▓▓████╬▓█▓▓╬╬╬▓▓█▓╬╬╬╬╬╬███
██████▓██▓███████▓╬╬╬▓▓╬▓▓██▓╬╬╬╬╬╬╬▓███
███████▓██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬████
███████▓▓██▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓████
████████▓▓▓█████▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█████
█████████▓▓▓█▓▓▓▓▓███▓╬╬╬╬╬╬╬╬╬╬╬▓██████
██████████▓▓▓█▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬▓███████
███████████▓▓█▓▓▓▓███▓╬╬╬╬╬╬╬╬╬▓████████
██████████████▓▓▓███▓▓╬╬╬╬╬╬╬╬██████████
███████████████▓▓▓██▓▓╬╬╬╬╬╬▓███████████
)"
              << "\n";
    std::cout << "That didn't work. You decide to give it another go.\n\n";
}

bool CheckCode(int Difficulty)
{
    bool PlayerResponseIsValid = PlayerResponseProduct == CodeProduct;

    PlayerResponseIsValid &= PlayerResponseSum == CodeSum;

    if (PlayerResponseIsValid)
    {
        PrintValidResponseMessage(Difficulty);
        return true;
    }

    PrintInValidResponseMessage();
    return false;
}

bool AttemptCodeHack(int Difficulty)
{
    std::cout << "Code Review\n";
    std::cout << "===========\n";
    std::cout << "✖ There are 3 numbers in the code\n";
    std::cout << "✖ They add up to: " << CodeSum << "\n";
    std::cout << "✖ The codes multiply to: " << CodeProduct << "\n\n";

    std::cout << "Enter the three codes:\n";
    std::cin >> PlayerResponse1 >> PlayerResponse2 >> PlayerResponse3;
    std::cout << "You responded with: " << PlayerResponse1 << ", ";
    std::cout << PlayerResponse2 << ", and " << PlayerResponse3 << "\n\n";

    PlayerResponseProduct = PlayerResponse1 * PlayerResponse2 * PlayerResponse3;
    PlayerResponseSum = PlayerResponse1 + PlayerResponse2 + PlayerResponse3;

    std::cout << "Product: " << PlayerResponseProduct << "\n";
    std::cout << "Sum: " << PlayerResponseSum << "\n\n";

    return CheckCode(Difficulty);
}

void generateMatrix(int Difficulty)
{
    FirstCode = rand() % Difficulty + Difficulty;
    SecondCode = rand() % Difficulty + Difficulty;
    ThirdCode = rand() % Difficulty + Difficulty;
    CodeSum = FirstCode + SecondCode + ThirdCode;
    CodeProduct = FirstCode * SecondCode * ThirdCode;
}

int main()
{
    srand(time(NULL));
    int MaxDifficulty = 3;
    int Difficulty = 1;

    IntroduceStory();

    while (Difficulty <= MaxDifficulty)
    {
        generateMatrix(Difficulty);

        if (AttemptCodeHack(Difficulty))
            Difficulty++;

        std::cin.clear();
        std::cin.ignore();
    }

    return 0;
}

1 Like

I ended up extending the project a bit and took a bit of a different approach to the difficulty ramp and figured out a few ways that I would probably evolve it now that I have it in a basic state.

Anyway, have a look:

#include <iostream>
#include <ctime>
#include <stdlib.h>


void DisplayIntroduction(int LevelDifficulty)
{
	// Clear the screen and print the welcome message
	system("CLS");
	std::cout << "**************************************" << std::endl;
	std::cout << "*                                    *" << std::endl;
	std::cout << "* TRIPLE X - SAFE CRACKER ADVENTURES *" << std::endl;
	std::cout << "*                                    *" << std::endl;
	std::cout << "**************************************" << std::endl;
	std::cout << "\nYou are an up and coming safe cracker breaking into a number of safes." << std::endl;
	std::cout << "You need to enter the correct codes to continue...You are currently on Level: " << LevelDifficulty << std::endl;
	
}

bool PlayGame(int LevelDifficulty, int ChangeCombination)
{

	DisplayIntroduction(LevelDifficulty);

	int HintThreshold{ 6 }; // Used to hide the wrong order hints
	int CodeRange{ 2 }; // Used as the base for ramping the difficulty

	// Used to ramp the difficulty.
	// Next evolution of this would be to change the literal to a var to allow for game start difficulty modes (Easy, Normal, Hard)
	int RangeMod{ LevelDifficulty / 3 }; 

	// Need to keep these vars throughout the course of the program.
	static int CodeA{ 0 };
	static int CodeB{ 0 };
	static int CodeC{ 0 };

	// Check if the player has solved the current code.
	if (ChangeCombination)
	{
		CodeA = rand() % CodeRange + RangeMod;
		CodeB = rand() % CodeRange + RangeMod;
		CodeC = rand() % CodeRange + RangeMod;
	}	

	const int CodeSum{ CodeA + CodeB + CodeC };
	const int CodeProduct{ CodeA * CodeB * CodeC };

	// Provide hints to the player
	std::cout << "\nThere are 3 digits in the code" << std::endl;
	std::cout << "The sum of the digits: " << CodeSum << std::endl;
	std::cout << "The product of the digits: " << CodeProduct << std::endl;

	int GuessA, GuessB, GuessC;
	std::cout << "\nInput your guesses separated by spaces and confirm with ENTER: ";
	std::cin >> GuessA >> GuessB >> GuessC;

	int GuessSum{ GuessA + GuessB + GuessC };
	int GuessProduct{ GuessA * GuessB * GuessC };

	bool bVictory{ false };
	bool bResultA{ GuessA == CodeA };
	bool bResultB{ GuessB == CodeB };
	bool bResultC{ GuessC == CodeC };


	if (bResultA && bResultB && bResultC)
	{
		bVictory = true;
	}

	if (GuessSum == CodeSum && GuessProduct == CodeProduct)
	{
		if (bVictory)
		{
			std::cout << "\nYou have cracked the combination, the safe is yours!\n\n" << std::endl;
		}
		else
		{
			std::cout << "\nYou have the correct numbers...but they are not in the correct order." << std::endl;

			if (LevelDifficulty < HintThreshold)
			{
				// If the player is below the threshold for hints, display the positions that are correct/incorrect.
				std::cout << "Hint: " << bResultA << bResultB << bResultC << "\n" << std::endl;
			}
			else
			{
				std::cout << std::endl;
			}
			
		}
	}
	else
	{
		// If the player fails trigger the alarm
		// Next evolution would be to allow a number of incorrect guesses on a safe before ending the game with arrest.
		std::cout << "\nYou have failed to open the safe, the alarm has be sounded!\n\n" << std::endl;
	}

	return bVictory;
	
}


int main()
{
	bool bLevelComplete{ false };
	bool bNewCombination{ true };
	int LevelDifficulty{ 1 };
	int MaxLevelDifficulty{ 10 };

	srand(time(NULL));
	
	while(true)
	{		
		bLevelComplete = PlayGame(LevelDifficulty, bNewCombination);
		bNewCombination = false;

		std::cin.clear();
		std::cin.ignore();

		// Add Pause to allow player to review before continuing
		std::cout << std::endl << std::flush;
		system("PAUSE");
		

		if (bLevelComplete)
		{
			// If the player has completed the hardest safe, they win the game
			// otherwise the player moves to the next safe to try again.
			// Next evolution might be adding a money display for amount of loot gained and allow the player to escape with the money
			// before facing the final safe.
			if (LevelDifficulty < MaxLevelDifficulty)
			{
				// Increment Difficulty Level
				++LevelDifficulty;
				bNewCombination = true;
			}
			else
			{
				std::cout << std::flush;
				system("CLS");
				std::cout << "\nYou have claimed all of the safes...you are a MASTER SAFE CRACKER!!!" << std::endl;
				break;
			}

		}
		
	}

	std::cout << std::endl;
	system("PAUSE");
	
	return 0;
}

Out of curiosity, has anyone come up with a way to prevent the intro message from being repeated EVERY time the game is run?

For example, if i run the game, the intro message displays (no surprise there). But i want to modify my game so that the Welcome message is not displayed after the player gets past level one. I want the intro to display ONLY on level 1. Anyone have any ideas? I will include my code below.

PS. Ignore the void PlayerLives() bit, it is something to come later :slightly_smiling_face:

#include <ctime>
using namespace std;

void PrintIntroduction(int Difficulty)
{
    //Print welcome messages to the terminal
    cout << "\n\nWelcome, Agent.\n";
    cout << "You are an indutrial spy being tasked with stealing the secrets of our rival company, the X Corporation.\n";
    cout << "In order to get to the files containing the secrets you seek, you must decipher the correct access codes to the LEVEL " << Difficulty << " Security Servers...\n";
    cout << "You only get 1 attempt to get the code correct before security is alerted. Good luck, Agent. Come back with those secrets, or don't come back at all.\n\n";
}

void PlayerLives()
{
    // This function will keep track of how many attemps the player has left until the game resets

}

bool PlayGame(int Difficulty)
{
    PrintIntroduction(Difficulty);

    //Declare 3 number code
    const int CodeA = rand() % Difficulty + Difficulty;
    const int CodeB = rand() % Difficulty + Difficulty;
    const int CodeC = rand() % Difficulty + Difficulty;

    const int CodeSum = CodeA + CodeB + CodeC;
    const int CodeProduct = CodeA * CodeB * CodeC;

    //Print CodeSum and CodeProduct to the terminal
    cout <<"There are 3 numbers in the code";
    cout << "\nThe code adds up to: " << CodeSum;
    cout << "\nThe code multiplies to give: " << CodeProduct << endl;

    //Obtain user input and store the guess
    int GuessA, GuessB, GuessC;
    cout << "\nPlease input your guess, separating each number with a space (ie. 1 2 3)" << endl;
    cin >> GuessA >> GuessB >> GuessC;

    int GuessSum = GuessA + GuessB + GuessC;
    int GuessProduct = GuessA * GuessB * GuessC;

    //Check for the win condition
    if (GuessSum == CodeSum && GuessProduct == CodeProduct)
    {
        cout << "\n*** Success! You found the right combination! We got a part of the files! Keep up the good work, Agent! ***";
        return true;
    }
    else
    {
        cout << "\n*** Failure! You entered the wrong combination! We lost the download! Try again, Agent! ***";
        return false;
    }
}

int main()
{
    srand(time(NULL)); // Create new random number sequence based on the time of day

    int LevelDifficulty = 1;
    const int MaxDifficulty = 5;

    while (LevelDifficulty <= MaxDifficulty) //Loop game until all levels are complete
    {
        bool bLevelComplete = PlayGame(LevelDifficulty);
        cin.clear(); // Clears any errors
        cin.ignore(); // Discards the buffer

        if (bLevelComplete)
        {
            ++LevelDifficulty;
        }      
               
    }
    cout << "\n*** Excellent work, Agent. We now have all the secrets of the X Corporation. Now get out of there before you are discovered! ***\n";
    return 0;
}

Since you are already passing the difficulty to the function that prints the introduction, I think you could use the difficulty in an “if-statement” to check, whether you are on level 1:

void PrintIntroduction(int Diffuculty)
{
        if(Difficulty == 1)
        { //Print the welcome message
          //...
        }
}
#include <iostream>
#include <iomanip>
#include <ctime>

int GetRandomNumber(int,int);
void FinishMessage(int,int);
void PlayGame();
void ClearInput();
int GetUserInput();
void WelcomeMenu(int,int);
void SumNProduct(int,int);
void PrintLevel (int);
int main(){
    PlayGame();
    return 0;
}
void PlayGame(){    
    srand(time(NULL));
    int CodeA=GetRandomNumber(1,10),CodeB=GetRandomNumber(1,10),CodeC=GetRandomNumber(1,10),Level=1,Mistake=0;
    while(Level<=10 && Mistake!=3){
        WelcomeMenu(Level,Mistake); 
        PrintLevel(Level);
        SumNProduct(CodeA+CodeB+CodeC,CodeA*CodeB*CodeC);
        std::cout<<"Enter Password : ";
        int GuessA=GetUserInput(),GuessB=GetUserInput(),GuessC=GetUserInput();
        int GuessSum=GuessA+GuessB+GuessC,GuessProd=GuessA*GuessB*GuessC;
        if(GuessSum==(CodeA+CodeB+CodeC)&&GuessProd==(CodeA*CodeB*CodeC)){
            std::cout<<"Level Unlocked\n";
            CodeA=GetRandomNumber(Level,Level);
            CodeB=GetRandomNumber(Level,Level);
            CodeC=GetRandomNumber(Level,Level);
            Level++;
        }else{
            std::cout<<"Failed to unlock for the ";
            switch(Mistake){
                case 0:std::cout<<"First Time\n";break;
                case 1:std::cout<<"Second Time\n";break;
                case 2:std::cout<<"Third Time\n";break;
            }
            Mistake++;
        }  
        ClearInput(); 
    }
    FinishMessage(Level,Mistake);
}
int GetRandomNumber(int Min,int Max){
    return(rand())%Max+Min;
}
void FinishMessage(int Level,int Mistakes){
    if(Level == 11){
        //Player won!!
        switch(Mistakes){
            case 0:std::cout<<"Amazing agent,\nYou penetrated the valut successfully without alerting anyone,\nClaim your reward\n";break;
            case 1:std::cout<<"Wonderful agent,\nYou penetrated the valut successfully with minimum effort,\nClaim your reward and start running\n";break;
            case 2:std::cout<<"Well done agent,\nYou penetrated the valut successfully,\nClaim your reward and start running the gaurds are after you\n";break;
        }
    }else{
        //Player Lost!!
        std::cout<<"Agent,\nYou Failed your mission,\n...\n";
    }
}
void WelcomeMenu(int Level,int Mistakes){
     std::cout<<"========================================================\n";
     std::cout<<"|  Hello agent Whiskey,                                |\n";
     std::cout<<"|  Today you will be trying to break into vaulte 77... |\n";
     std::cout<<"|  Good Luck                                           |\n";
     std::cout<<"========================================================\n";
     std::cout<<"|  The Pass is made out of 3 numbers try to find them  |\n";
     std::cout<<"|  Hint: with each level you will recieve the sum and  |\n";
     std::cout<<"|  the product of these 3 numbers...                   |\n";
     std::cout<<"|  Correct:"<<std::setw(2)<<(Level-1)<<"/10                         Mistakes:"<<std::setw(1)<<Mistakes<<"/3  |\n";  
     std::cout<<"========================================================\n";
}
void SumNProduct(int CodeSum,int CodeProd){
     std::cout<<"========================================================\n";
     std::cout<<"|  The sum of the 3 numbers: a+b+c="<<std::setw(4)<<CodeSum<<"                |\n";
     std::cout<<"|  The product of the 3 numbers: a*b*c="<<std::setw(4)<< CodeProd <<"            |\n";
     std::cout<<"========================================================\n";
}
void PrintLevel(int Lvl){
    std::cout<<"Level "<<Lvl<<std::endl;
}
int GetUserInput(){
    int temp;
    std::cin>>temp;
    return temp;
}
void ClearInput(){
    std::cin.clear();
    std::cin.ignore();
}

1 Like

I have done some c++ but i thought a refresher of the basics would be good, so i dived in and this is what i made

The program has a delay between each character as it is displayed giving a nice terminal feel.
It also uses System("CLS"); (a little bit hacky - there are other ways) to clear the console when changing screens. (which may cause the program to crash in specific circumstances.)

#include <windows.h>
#include <iostream>
#include <ctime>
#include <stdlib.h>
#include <string>

 /*
    Author: Geoffrey Hinds
    GDD: You are a bounty hunter you have tracked a target to this location.
    Your target is hiding in a secured bunker. You will have to hack the security protocols to get to them.
    You find a terminal and get started. Solve math problems to advance.
       
 */

void TypeString(std::string str, int speed) // types strings one letter at a time at the requested speed
{
    for (auto s : str)
    {                
        std::cout << s;
        Sleep( speed );
    }  
}

void PrintTop()
{
    system("CLS");
    TypeString("\n  ____________________________________________", 1);
    TypeString("\n //                                          \\\\", 1);
    TypeString("\n//********************************************\\\\", 1);
    TypeString("\n||********************************************||", 1);
}

void PrintBottom(bool ClearScreen)
{
    TypeString("\n||********************************************||", 1);
    TypeString("\n\\\\********************************************//", 1);
    TypeString("\n \\\\__________________________________________//\n", 1);
    Sleep(1000);
    if (ClearScreen)
    {
        system("CLS");
    }    
}

void PrintIntroduction(int Difficulty, int MaxDifficulty)
{
    // Print welcome messages to terminal
    if (Difficulty == 1)
    {
        PrintTop();
        TypeString("\n|| Your target is hiding in a secured bunker  ||", 10);
        TypeString("\n|| You will have to hack the security         ||", 3);
        TypeString("\n|| protocols to get to them.                  ||", 3);
        TypeString("\n||                                            ||", 1);
        PrintBottom(false);

        Sleep(3000);
        system("CLS");
        
        PrintTop();
        std::string str = "\n|| There are ";
        str += std::to_string(MaxDifficulty);
        str += " levels of protocols!           ||";
        TypeString(str, 10);
        std::string str2 = "\n||  Security protocol level ";
        str2 += std::to_string(Difficulty);
        str2 += ":Enabled         ||";
        TypeString(str2, 10);
        TypeString("\n||                                            ||", 1);
        TypeString("\n|| Enter the correct code to continue...      ||", 3);
    }
    else
    {
        PrintTop();
        std::string str2 = "\n||  Security protocol level ";
        str2 += std::to_string(Difficulty);
        str2 += ":Enabled         ||";
        TypeString(str2, 10);

        if (Difficulty != MaxDifficulty)
        {
            std::cout << "\n||  ";
            std::string str = "You have ";
            str += std::to_string(MaxDifficulty-Difficulty);
            str += " levels left to go!             ";
            TypeString(str, 3);
            std::cout << "||";
        }        
        else
        {
            std::cout << "\n";
            TypeString("||  This is the last security level!          ||", 3);
        }
        
    }
}

bool PlayGame(int Difficulty, int MaxDifficulty) 
{
    PrintIntroduction(Difficulty, MaxDifficulty);

    // Setup numbers
    const int CodeA = rand() % Difficulty + Difficulty;    
    const int CodeB = rand() % Difficulty + Difficulty;
    const int CodeC = rand() % Difficulty + Difficulty;

    const int CodeSum       = CodeA + CodeB + CodeC;
    const int CodeProduct   = CodeA * CodeB * CodeC;
    
    // Print sum and product to the terminal
    
    TypeString("\n||********************************************||", 1);
    TypeString("\n||  + There are three numbers in the code     ||", 3);
    TypeString("\n||", 1);
    std::string str = "  + The codes add-up to: ";
    str += std::to_string(CodeSum);
    TypeString(str, 3);
    if (CodeSum >= 10)
    {
        if (CodeSum >= 100)
        {
            TypeString("                ||", 3);
        }
        else
        {
            TypeString("                 ||", 3);
        }
        
    }
    else 
    {                
        TypeString("                  ||", 3);
    }   
    TypeString("\n||", 1);
    str = "  + The codes multiply to give: ";
    str += std::to_string(CodeProduct);
    TypeString(str, 3);
    if (CodeProduct >= 10)
    {
        if (CodeProduct >= 100)
        {
            TypeString("         ||", 3);
        }
        else
        {
            TypeString("          ||", 3);
        }
        
    }
    else
    {                    
            TypeString("           ||", 3);
    }   
    TypeString("\n||********************************************||", 1);
    TypeString("\n||  Enter your three guesses below...         ||", 3);    
    PrintBottom(false);

    // Store player guess
    int GuessA, GuessB, GuessC;
    std::cin >> GuessA >> GuessB >> GuessC;

    int GuessSum = GuessA + GuessB + GuessC;
    int GuessProduct = GuessA * GuessB * GuessC;

    // Check if players guess is correct
    if (GuessSum == CodeSum && GuessProduct == CodeProduct)
    {
        if (Difficulty == MaxDifficulty)
        {
            PrintTop();
            TypeString("\n||  You Hacked the last protocol!             ||", 3);
            TypeString("\n||  Access Granted                            ||", 10);
            TypeString("\n||  Bunker door opening...                    ||", 15);
            TypeString("\n||                                            ||", 1);
            PrintBottom(true);
        }
        else
        {
            PrintTop();
            TypeString("\n||  ", 1);
            std::string str = "You Hacked the level ";
            str += std::to_string(Difficulty);
            str += " security protocol! ";
            TypeString(str, 30);
            TypeString("||", 1);
            PrintBottom(true);
        }

        return true;
    }
    else
    {
        PrintTop();
        std::cout << "\n";
        TypeString("||  The HackFailed! Try Again...              ||", 30);
        PrintBottom(true);

        return false;
    }    
}

int main()
{
    srand(time(NULL));
    int LevelDifficulty = 1;
    const int MaxDifficulty = 5;

    while (LevelDifficulty <= MaxDifficulty)
    {
        bool bLevelComplete = PlayGame(LevelDifficulty, MaxDifficulty);
        std::cin.clear();  // Clears any errors
        std::cin.ignore(); // Discards the buffer

        if (bLevelComplete)
        {
            ++LevelDifficulty;
        }
        
    }
        PrintTop();
        TypeString("\n||  It's about time you finished!             ||", 15);
        TypeString("\n||  My granny can hack faster than you!       ||", 15);
        TypeString("\n||  Well your targets inside! Go get em!!!    ||", 15);
        TypeString("\n||  Don't forget they're worth more alive!    ||", 15);        
        PrintBottom(false);

    return 0;
}

Source Code and Windows Binary TripleX.zip (163.7 KB)

Here’s my version of Triple X :slight_smile:

With my narrative being that you are unlocking a phone, I kept the difficulty between 1-4, so the player would only ever enter single-digit combinations. The final difficulty felt pretty challenging.

I also added my own small touch, where the player can only guess the PIN incorrectly 3 times, or the phone will self destruct. The number of failed attempts is reset if the player gets the answer right.

#include <iostream>
#include <ctime>


void PrintIntroduction()
{
    std::cout << "\n\nFor additional security, and to improve your overall intelligence,\n";
    std::cout << "you now need to solve a problem to unlock your smartphone. \n";  
}

bool PlayGame(int Difficulty)
{
    //DECLARATION STATEMENTS
    const int NumA = rand() % Difficulty + Difficulty;
    const int NumB = rand() % Difficulty + Difficulty;
    const int NumC = rand() % Difficulty + Difficulty;

    int NumSum = NumA + NumB + NumC;
    int NumProduct = NumA * NumB * NumC;

    //Debugging
   std::cout << NumA << NumB << NumC;

    std::cout << "\n+Your PIN is three numbers.";
    std::cout << "\n+The sum of these numbers is " << NumSum;
    std::cout << "\n+The product of these numbers is " << NumProduct;
    std::cout << "\nWhat is the PIN?\n";
    std::cout << "Press enter, or separate the numbers with a space \n"; 

    //Store player guess
    int GuessA, GuessB, GuessC;
    std::cin >> GuessA >> GuessB >> GuessC;
    std::cout << "You entered: " <<GuessA << " " << GuessB << " " << GuessC << std::endl;

    int GuessSum = GuessA + GuessB + GuessC;
    int GuessProduct = GuessA * GuessB * GuessC;

    //Check if guess is correct
    if(GuessSum == NumSum && GuessProduct == NumProduct) 
    {
        std::cout << "\nAuthentication Successful.\nYou successfuly solved a level " << Difficulty << " puzzle\n";
        return true;
    }
    else 
    {
        std::cout << "\nIncorrect PIN - Please try again\n";
        return false;
    }
}


int main()
{
    srand(time(NULL));

    PrintIntroduction();

    int LevelDifficulty = 1;
    const int MaxDifficulty = 4;
    int FailedAttempts = 0;
    
    while(LevelDifficulty <= MaxDifficulty)
    {
        bool bLevelComplete = PlayGame(LevelDifficulty);
        std::cin.clear();
        std::cin.ignore();

        if(bLevelComplete)
        {
            ++LevelDifficulty;
            FailedAttempts = 0;
        }
        else
        {
            ++FailedAttempts;
            if (FailedAttempts >= 3)
            {
                std::cout <<"\nYou have entered too many incorrect passwords.\nThe phone will now self destruct.";
                return 0;
            }
        }
    }
    std::cout << "Congratulations. You have solved the hardest puzzle we had.\nYou are a superior human and ought to be proud.";
    return 0;
}

Privacy & Terms