0% found this document useful (0 votes)
20 views2 pages

ميحرلا نمحرلا الله مسب Mosab2a Questions #2, #3 Pizza !: Input

This document provides an example of an interactive guessing game where one player thinks of a secret binary code and the other player asks yes/no questions to try and guess the code. It explains that the guessing player will provide a binary code as a question, and the holding player will reply with the number of matching digits between the question and secret codes. The goal is for the guessing player to use the answers to deduce the secret code within the fewest number of questions. An example game is shown where the secret code is 101, and the guesser determines it in 3 questions.

Uploaded by

Ahmed Ismail
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views2 pages

ميحرلا نمحرلا الله مسب Mosab2a Questions #2, #3 Pizza !: Input

This document provides an example of an interactive guessing game where one player thinks of a secret binary code and the other player asks yes/no questions to try and guess the code. It explains that the guessing player will provide a binary code as a question, and the holding player will reply with the number of matching digits between the question and secret codes. The goal is for the guessing player to use the answers to deduce the secret code within the fewest number of questions. An example game is shown where the secret code is 101, and the guesser determines it in 3 questions.

Uploaded by

Ahmed Ismail
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Mosab2a Questions #2 , #3

Pizza !
A Pizza chef needs to sort the pizza in the facultys restaurant to reduce the delay in his
service .
NOTE : the only move available is to flip the pizza upside down (see example)
:D http://www.youtube.com/watch?v=O04A_qKFIhA :
6 5
Input :
First line is N , which is the number of pizzas . Followed by N lines of unsorted pizza sizes
(integers) , notice that all sizes are different , no repeated values.
Required Output :
The least number of moves required to sort them .
Example :
Input :
4
8
2
1
3
Steps (just for clarification , not required in the output , but it can be a bonus ;))
Move
8
2
1
3
Output :
3

first
3
1
2
8

second
2
1
3
8

third
1
2
3
8

The Code !
Your friend challenges you to know what code he is thinking of . You know his code is binary
with n number of digits .
You are allowed to ask him n questions or less in the form of n-digit code of your choice , he
will then tell you how many digits matches between your code and his .
You will output the question , I will enter the number of matches in my code and your
question code .
Digit ..
Digit , 0 , 0000 , 0111
3 1111 , ) , (
..
NOTE : that this program is interactive , means you will ask the user and he will reply to
you as well .
Input :
First input will be the number of digits of my binary code .
Each OUTPUT will be followed by an INPUT from me with the number of correct matches
between your question code and the code in my head
:D ,
Output :
N or less questions (of your choice) , but you must CHOOSE and PROCESS the result well in
order to guess my code .The final output should be the code .
Example :
My code is 101.
, :
Input

Output

3
111
2
000
1
101
3
101

You might also like