Question: Imagine a future generation communicating via an emoji - based language. They can also do some basic math with the same language. Consider the following
Imagine a future generation communicating via an emojibased language. They can also
do some basic math with the same language. Consider the following example:
Our goal is to interpret this particular mysterious addition operation given in above figure. More specifically, given the two emojicexpressions
as summands and their addition result as another emojicexpression above, we would like to assign a different digit to
each emoji in the emojicexpressions in the two summands and the summation result without leading zeros ie the first digit of
each number, the couple and family emojis in the above example, cannot be zero such that the summation in our decimal system
is correct. An example solution is as follows:
import itertools
function EnumerateOrderedDigitsint n:
return listitertoolspermutationsrangen
function SolveMyEmojiPuzzle:
Emojis couplefamilyheartsmileydogcat
OrderedDigits EnumerateOrderedDigits
OrderedDigits od for od in OrderedDigits if od and od
ListofEmojiDigitAssignments dictzipEmojisod for od in OrderedDigits
Solutions
for assignment in ListofEmojiDigitAssignments:
if assignment correctly solves the puzzle:
Add summandsummation result to Solutions
# Eg we should have in Solutions
return Solutions
a Implement the algorithm provided as in the pseudocode above. Note that emoji has all lowercase letters. Your function should
return list of all the solutions stored as tuple of strings in the format digitnumberdigitnumber correspondingsum
Sample function call and expected inputsoutputs are provided below.
emojisolutions SolveMyEmojiPuzzle # emojisolutions is a list of tuples of strings
# emojisolutions code in python
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
