vkn84527 / Guessing-Number-through-4-digit-pin

A low-level implementation of the classic game “Mastermind”. I write a program that generates a four-digit random code and the user needs to guess the code in 10 tries or less. If any digit out of the guessed four-digit code is wrong, the computer should print out “B”. If the digit is correct but at the wrong place, the computer should print “Y”. If both the digit and position is correct, the computer should print “R”.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Guessing-Number-through-4-digit-pin

A low-level implementation of the classic game “Mastermind”. I write a program that generates a four-digit random code and the user needs to guess the code in 10 tries or less. If any digit out of the guessed four-digit code is wrong, the computer should print out “B”. If the digit is correct but at the wrong place, the computer should print “Y”. If both the digit and position is correct, the computer should print “R”.

Program Preview :

First, I write a function to generate a random four digit code using Python’s random module. Next, we define a function that asks for user input. Finally, we write a function that compares the generated code to the guessed code and gives appropriate results.

About

A low-level implementation of the classic game “Mastermind”. I write a program that generates a four-digit random code and the user needs to guess the code in 10 tries or less. If any digit out of the guessed four-digit code is wrong, the computer should print out “B”. If the digit is correct but at the wrong place, the computer should print “Y”. If both the digit and position is correct, the computer should print “R”.


Languages

Language:Python 100.0%