You are at a restaurant eating lunch with a friend. After the meal, your friend realizes they left their wallet at home. Your friend gives you a piece of silver….
Write a recursive function that determines whether or not a word can be spelled using only element symbols.
Each chemical element has a standard symbol that is one, two or three letters long. One game that some people like to play is to determine whether or not a word can be spelled using only element symbols. For example, silicon can be spelled using the symbols Si, Li, C, O and N. However, hydrogen cannot be spelled with any combination of element symbols.
Write a recursive function that determines whether or not a word can be spelled using only element symbols. Your function will require two parameters: the word that you are trying to spell and a list of the symbols that can be used. It will return a string containing the symbols used to achieve the spelling as its result, or an empty string if no spelling exists. Capitalization should be ignored when your function searches for a spelling.
Create a program that uses your function to find and display all of the element names that can be spelled using only element symbols. Display the names of the elements along with the sequences of symbols. For example, one line of your output will be:
Silver can be spelled as SiLvEr
Your program will use the elements data set, which can be downloaded from the author’s website. This data set includes the names and symbols of all 118 chemical elements.