Adding Words Kattis Solution in Python 3
If you want to look at the question of adding words on kattis click on this Kattis Adding Words.
How did I solve it?
Whenever the definition of variables was given I stored it in 'words' dictionary and its reverse in the 'reverse' dictionary. When the new update of the variable was given I deleted it from the reverse dictionary if it is already present in the key of words dictionary and then updated both dictionaries.
When the calc expression was given I converted it into the mathematical expression by removing the keywords and equal sign from it. Then I evaluated the expression using the eval() function. After that, I check whether the result value is present in the reverse dictionary or not. Then accordingly printed the result. If clear keywords were given then I cleared both dictionaries. The program code for the kattis adding words solution in python is given below.
Buy the software from amazon so that you can make the best use of your computing devices from the link given below.