-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathana.spd
More file actions
executable file
·49 lines (41 loc) · 1.12 KB
/
ana.spd
File metadata and controls
executable file
·49 lines (41 loc) · 1.12 KB
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
43
44
45
46
47
48
49
#!/usr/local/bin/spd
class Anagrams
|dictionary of string| out
|string| orig
function Split (|string| v, |string| remain)
for i in 1 to remain.Length
|| sub = remain[0, i]
if Anagrams[sub]
|| v2 = (sub, v + " " + sub)(!v)
|| remain2 = remain[i...]
.split(v2, remain2)
else
v2 = v2.sort(' ')
.out[v2] = v2
function Find (|string| progress, |string| inside, |int| depth)
for i in progress.Length + 1
|| Variant = progress.insert(inside, i)
if depth < .orig
.find(Variant, string.byte(.orig[depth]), depth+1)
else
.split("", variant)
module
|dictionary| D
syntax access (|string| s, |bool|)
if s.length > 1: return .d[s]
return s == "i" or "a"
function Find (|string| s, |dictionary of string|)
s = s.Remove(~charset.LettersOnly)
if !.d
|| data = ""
time "read": data = file.words.ReadAll
time "lower": data = data.LowerCase
time "dict": .d = data.dict
rz = Dictionary()
time "anagram"
Anagrams(rz, s).find("", "", 0)
main (|string| word="hedgehog")
time "total"
|| d = Anagrams.find(word)
for v in d
printline v