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:
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)