An ionic compound is named like so:
(metal name) (non-metal suffixed with -ide). Here is a list of all the suffixes that need to be replaced with
-on -ogen -ygen -ine -orus -ur -ic -ium
The number of atoms of each element in the compound is not used in naming ionic compounds. Ignore the multivalent metal naming rules.
NaCl -> sodium + chlorine -> sodium chloride. K2S -> potassium + sulphur -> potassium sulphide (or sulfide). Yb2P3 -> ytterbium + phosphorus -> ytterbium phosphide. PbTe2 -> lead + tellurium -> lead telluride.
A string containing an ionic compound (
Yb2P3) will be given as input. No polyatomic ions will be given. The program has to output the name of this compound.
Since nobody wants to compile the periodic table data themselves, here is a paste that has the names, symbols, and whether or not it is a metal of each element, in this order:
(name) (symbol) (is metal?). You can save this to an external file (the length of the file will not be counted), or you can store the data within your program (just discount the length of that string from there.) You may not need all the information provided. Every element is seperated by a newline.
As always with code golf challenges, shortest code wins.