stoichiograph

Spell words with elemental symbols from the periodic table.
git clone git://git.amin.space/stoichiograph.git
Log | Files | Refs | LICENSE

commit 2706cbee644f413e519770fe6e345d66fe5dbc5d
parent 527c81ce07c6fbccd59de88fd2f7bb4de6eaf1f5
Author: amin <dev@aminmesbah.com>
Date:   Wed, 27 Jan 2016 04:11:49 +0000

find matching chars between word and elemental symbols

FossilOrigin-Name: 2bc0b8f3ba0cc50f0da6f019544b44aa1d359df2561c1e9323d517628287e366
Diffstat:
Mspeller.py | 17+++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/speller.py b/speller.py @@ -1,18 +1,27 @@ import csv def main(): - symbols = get_symbols('elements.csv') - print(symbols) + symbols = get_csv_data('elements.csv', 1) + test_word = "Osiris" + print(find_matches(test_word, symbols)) +def find_matches(word, symbols): + matches = [] -def get_symbols(file_name): + for char in word: + single = char + matches += (x for x in symbols if x == char) + + return matches + +def get_csv_data(file_name, column): symbols = [] with open(file_name) as infile: csv_reader = csv.reader(infile, skipinitialspace=True, delimiter=',') next(csv_reader, None) for row in csv_reader: - symbols.append(row[1]) + symbols.append(row[column]) return symbols