This workshop project explores the algorithmic complexities (speed and memory) of checking if an input word can be "spelled" (case-insensitive) by a sequence of the chemical symbol abbreviations from the standard periodic table.
For example, the word "accept" can be spelled with Ac (Actinium) + Ce (Cerium) + Pt (Platinum).
The goal of this tool is to check if an input word can be "spelled" with the periodic table symbols, and then to show that sequence of element symbols.
-
Check out the
start-herebranch. -
Consult the
app.jsmodule for the app logic already implemented:-
Calls
Speller.check(..)to attempt to spell an input word with the periodic table element symbols. -
Calls
Speller.lookup(..)to pull the periodic table element by its symbol (case-insensitive). -
Note also the list of known test words in code comments. You'll want to use these as you test your solution!
-
-
Now consult the
speller.jsmodule for the algorithm logic to be implemented (look for theTODOcomments):-
The
loadPeriodicTable()function loads theperiodic-table.jsonfile into theelementsvariable. -
The
check(..)function accepts an input word as a string (all lowercase letters) and returns an array (empty array if word couldn't be spelled). -
The
lookup(..)function accepts a symbol (as a string) and returns the periodic table element's entry/info, used to render the spelling as periodic table elements.
-
-
When you're ready, or if you get stuck in your own implementation, check out the
option-1andoption-2branches and compare your solution to the ones provided.
This workshop problem is similar to/inspired by ChemSpeller.
The JSON file holding periodic table elements was adapted from: https://github.com/Bowserinator/Periodic-Table-JSON/blob/master/PeriodicTableJSON.json
All code and documentation are (c) 2023 Kyle Simpson and released under the MIT License. A copy of the MIT License is also included.
