Skip to content

Instantly share code, notes, and snippets.

@orico
Created July 8, 2019 14:30
Show Gist options
  • Save orico/d50acc8576510da78323bdf8c2925151 to your computer and use it in GitHub Desktop.
Save orico/d50acc8576510da78323bdf8c2925151 to your computer and use it in GitHub Desktop.
example: SortedStringTrie({'ate': 3, 'cat': 5, 'do': 1, 'dog': 2, 'gate': 4, 'the': 0})
prefixes example: ['do', 'dog']
starting..
recoursively working on string: thedogatethecat
progress: t
progress: th
progress: the
found: ['the'] for: the
possible sentences {}
possible sentences {'the': {}}
s: dogatethecat poss: {}
recoursively working on string: dogatethecat
progress: d
progress: do
found: ['do', 'dog'] for: do
possible sentences {}
possible sentences {'do': {}}
s: gatethecat poss: {}
recoursively working on string: gatethecat
progress: g
progress: ga
progress: gat
progress: gate
found: ['gate'] for: gate
possible sentences {}
possible sentences {'gate': {}}
s: thecat poss: {}
recoursively working on string: thecat
progress: t
progress: th
progress: the
found: ['the'] for: the
possible sentences {}
possible sentences {'the': {}}
s: cat poss: {}
recoursively working on string: cat
progress: c
progress: ca
progress: cat
found: ['cat'] for: cat
possible sentences {}
possible sentences {'cat': {}}
s: poss: {}
recoursively working on string:
returning..
returning..
progress: thec
progress: theca
progress: thecat
returning..
progress: gatet
progress: gateth
progress: gatethe
progress: gatethec
progress: gatetheca
progress: gatethecat
returning..
progress: dog
found: ['dog'] for: dog
possible sentences {'do': {'gate': {'the': {'cat': {}}}}}
possible sentences {'do': {'gate': {'the': {'cat': {}}}}, 'dog': {}}
s: atethecat poss: {}
recoursively working on string: atethecat
progress: a
progress: at
progress: ate
found: ['ate'] for: ate
possible sentences {}
possible sentences {'ate': {}}
s: thecat poss: {}
recoursively working on string: thecat
progress: t
progress: th
progress: the
found: ['the'] for: the
possible sentences {}
possible sentences {'the': {}}
s: cat poss: {}
recoursively working on string: cat
progress: c
progress: ca
progress: cat
found: ['cat'] for: cat
possible sentences {}
possible sentences {'cat': {}}
s: poss: {}
recoursively working on string:
returning..
returning..
progress: thec
progress: theca
progress: thecat
returning..
progress: atet
progress: ateth
progress: atethe
progress: atethec
progress: atetheca
progress: atethecat
returning..
progress: doga
progress: dogat
progress: dogate
progress: dogatet
progress: dogateth
progress: dogatethe
progress: dogatethec
progress: dogatetheca
progress: dogatethecat
returning..
progress: thed
progress: thedo
progress: thedog
progress: thedoga
progress: thedogat
progress: thedogate
progress: thedogatet
progress: thedogateth
progress: thedogatethe
progress: thedogatethec
progress: thedogatetheca
progress: thedogatethecat
returning..
the do {'gate': {'the': {'cat': {}}}}
the dog {'ate': {'the': {'cat': {}}}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment