-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCaffeineFix.py
More file actions
43 lines (38 loc) · 866 Bytes
/
CaffeineFix.py
File metadata and controls
43 lines (38 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Copyright (c) 2010 NextMove Software, Inc.
import drug_synonyms as CaffeineFixDictionary
def is_correct(s):
l = len(s)
if l == 0:
return False
ch = s[0]
state = 0
i = 1
while True:
if CaffeineFixDictionary.ch(state) == ch:
if i == l:
return CaffeineFixDictionary.valid(state)
state = CaffeineFixDictionary.down(state)
ch = s[i]
i = i+1
else:
state = CaffeineFixDictionary.across(state)
if state == 0:
return False
def is_prefix(s):
l = len(s)
if l == 0:
return True
ch = s[0]
state = 0
i = 1
while True:
if CaffeineFixDictionary.ch(state) == ch:
if i == l:
return True
state = CaffeineFixDictionary.down(state)
ch = s[i]
i = i+1
else:
state = CaffeineFixDictionary.across(state)
if state == 0:
return False