How to resolve the algorithm Guess the number/With feedback step by step in the PARI/GP programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Guess the number/With feedback step by step in the PARI/GP programming language

Table of Contents

Problem Statement

Write a game (computer program) that follows the following rules:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Guess the number/With feedback step by step in the PARI/GP programming language

Source code in the pari/gp programming language

guess_the_number(N=10)={
	a=random(N);
	print("guess the number between 0 and "N);
	for(x=1,N,
		if(x>1,
			if(b>a,
				print("guess again lower")
			,
				print("guess again higher")
		);
		b=input();
		if(b==a,break())
	);
	print("You guessed it correctly")
};

  

You may also check:How to resolve the algorithm Repeat a string step by step in the jq programming language
You may also check:How to resolve the algorithm Stirling numbers of the first kind step by step in the Nim programming language
You may also check:How to resolve the algorithm Increment a numerical string step by step in the Pike programming language
You may also check:How to resolve the algorithm Pinstripe/Display step by step in the Befunge programming language
You may also check:How to resolve the algorithm Parametric polymorphism step by step in the Nim programming language