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

commit ced11be761b4898fa042fba45e17e68c4d5e1ccf
parent 594dcc343ea4f9e58d42befc0f5505625c5107c6
Author: amin <>
Date:   Sun, 31 Jan 2016 23:11:51 +0000

make find_matches() find the indices of matching symbols

FossilOrigin-Name: f898716621d34c43f49646c6008915f2cd30279d4b48e4b469f5d55353a14860
Diffstat: | 4++-- | 13++++++++++++-
2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/ b/ @@ -15,7 +15,6 @@ def main(): print(single_matches, pair_matches) - def tokenize_sequence(sequence): t = namedtuple('Tokens', (['single', 'pair'])) @@ -28,12 +27,13 @@ def tokenize_sequence(sequence): def find_matches(sequence, symbols): matches = [] + indices = [] lower_symbols = [i.lower() for i in symbols] lower_sequence = [i.lower() for i in sequence] for i in lower_sequence: matches += (x for x in lower_symbols if x == i) - # TODO: Make this return an array of indices + indices += (lower_symbols.index(x) for x in lower_symbols if x == i) return matches diff --git a/ b/ @@ -30,7 +30,18 @@ class TokensTest(unittest.TestCase): class FileTest(unittest.TestCase): file_name = "elements.csv" - proper_data = ['H', 'He', 'Li', 'Be', 'B', 'C', 'N', 'O', 'F', 'Ne', 'Na', 'Mg', 'Al', 'Si', 'P', 'S', 'Cl', 'Ar', 'K', 'Ca', 'Sc', 'Ti', 'V', 'Cr', 'Mn', 'Fe', 'Co', 'Ni', 'Cu', 'Zn', 'Ga', 'Ge', 'As', 'Se', 'Br', 'Kr', 'Rb', 'Sr', 'Y', 'Zr', 'Nb', 'Mo', 'Tc', 'Ru', 'Rh', 'Pd', 'Ag', 'Cd', 'In', 'Sn', 'Sb', 'Te', 'I', 'Xe', 'Cs', 'Ba', 'La', 'Ce', 'Pr', 'Nd', 'Pm', 'Sm', 'Eu', 'Gd', 'Tb', 'Dy', 'Ho', 'Er', 'Tm', 'Yb', 'Lu', 'Hf', 'Ta', 'W', 'Re', 'Os', 'Ir', 'Pt', 'Au', 'Hg', 'Tl', 'Pb', 'Bi', 'Po', 'At', 'Rn', 'Fr', 'Ra', 'Ac', 'Th', 'Pa', 'U', 'Np', 'Pu', 'Am', 'Cm', 'Bk', 'Cf', 'Es', 'Fm', 'Md', 'No', 'Lr', 'Rf', 'Db', 'Sg', 'Bh', 'Hs', 'Mt', 'Ds', 'Rg', 'Uub', 'Uut', 'Uuq', 'Uup', 'Uuh', 'Uus', 'Uuo'] + proper_data = ['H', 'He', 'Li', 'Be', 'B', 'C', 'N', 'O', 'F', 'Ne', + 'Na', 'Mg', 'Al', 'Si', 'P', 'S', 'Cl', 'Ar', 'K', 'Ca', + 'Sc', 'Ti', 'V', 'Cr', 'Mn', 'Fe', 'Co', 'Ni', 'Cu', 'Zn', + 'Ga', 'Ge', 'As', 'Se', 'Br', 'Kr', 'Rb', 'Sr', 'Y', 'Zr', + 'Nb', 'Mo', 'Tc', 'Ru', 'Rh', 'Pd', 'Ag', 'Cd', 'In', 'Sn', + 'Sb', 'Te', 'I', 'Xe', 'Cs', 'Ba', 'La', 'Ce', 'Pr', 'Nd', + 'Pm', 'Sm', 'Eu', 'Gd', 'Tb', 'Dy', 'Ho', 'Er', 'Tm', 'Yb', + 'Lu', 'Hf', 'Ta', 'W', 'Re', 'Os', 'Ir', 'Pt', 'Au', 'Hg', + 'Tl', 'Pb', 'Bi', 'Po', 'At', 'Rn', 'Fr', 'Ra', 'Ac', 'Th', + 'Pa', 'U', 'Np', 'Pu', 'Am', 'Cm', 'Bk', 'Cf', 'Es', 'Fm', + 'Md', 'No', 'Lr', 'Rf', 'Db', 'Sg', 'Bh', 'Hs', 'Mt', 'Ds', + 'Rg', 'Uub', 'Uut', 'Uuq', 'Uup', 'Uuh', 'Uus', 'Uuo'] def test_file_contains_proper_data(self): data = speller.get_csv_data(self.file_name, 1)