Python Forum
Help - random number/letter guessing game
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help - random number/letter guessing game
#1
I cannot seem to map a random letter to a random number for the question below:

A single-player guessing game uses alphabets in place of digits to make a puzzle out of the addition of two single-digit numbers and the answer. The letters a to j are randomly ordered and each digit 0 to 9 are represented by corresponding letters by position. The player solves the puzzle by guessing which digits fit into the puzzle. Study the sample program output and the accompanying notes for the problem requirements. User input is shown underlined.

*Cheat Sheet*
8
+ 6
----
14
----
*End Cheat Sheet*
a
+ f
----
ge
----
Enter a letter: g
Enter a digit: 1
You guessed 1 for g correctly. Well done
a
+ f
----
1e
----
Enter a letter: a
Enter a digit: 5
(a, 5) is not correct. Try again

Develop a program that uses the only collection type str for any collection of values, and allows a player to play ONE (1) game to solve a puzzle.
You may use this function to map digits to letters:
from random import shuffle
def getLetterMap():
stringList = list('abcdefghij')
shuffle(stringList)
return ''.join(stringList)
Reply
#2
Given that stringlist(...) is shuffled, (after you called the getLetterMap() function),
there is a natural way you could assign numbers to these letters.
You could start at zero, if that is OK for the assignment.

paul
It is more important to do the right thing, than to do the thing right.(P.Drucker)
Better is the enemy of good. (Montesquieu) = French version for 'kiss'.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question Play again, in a guessing game banidjamali 4 11,699 Jan-22-2021, 06:23 AM
Last Post: banidjamali
  Dynamically chosing number of players in a "game" nsadams87xx 5 4,162 Jul-17-2020, 02:00 PM
Last Post: deanhystad
  Can someone help me optimize this game for large number of strings Emekadavid 13 4,950 Jul-06-2020, 06:16 PM
Last Post: deanhystad
  making a guessing number game blacklight 1 2,196 Jul-02-2020, 12:21 AM
Last Post: GOTO10
  Guessing game with 4 different digits LinseyLogi 6 3,645 Mar-29-2020, 10:49 AM
Last Post: pyzyx3qwerty
  Guess the number game jackthechampion 5 3,181 Mar-07-2020, 02:58 AM
Last Post: AKNL
  Asking for help in my code for a "Guess the number" game. Domz 5 3,813 Aug-14-2019, 12:35 PM
Last Post: perfringo
  About the random number generating shang2019 2 2,577 Jan-13-2019, 02:40 AM
Last Post: gitiya
  Guessing game with comparison operators Drone4four 9 13,781 Dec-02-2018, 06:12 PM
Last Post: ichabod801
  Guess a number game Drone4four 4 5,263 Nov-16-2018, 03:56 AM
Last Post: Drone4four

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020