aboutsummaryrefslogtreecommitdiff
path: root/challenge-081/richard-park/apl/CommonBaseString.aplf
blob: 8bb924deb859debfe1f3f2bbcef405377dccc410 (plain)
1
2
3
4
5
6
7
8
9
10
11
 CommonBaseString{
     FindBaseStrings{
         1
         =≢⍵:                                   ⍝ Reached end of string
         bs                                   ⍝ Base String candidate
         bs{(bs)≡,↑∪(1)⍵:bs  }   ⍝ Substring is a base string, else ⍬
         bs:(+1)                             ⍝ If no base string, increment substring length and try again
         ()~bs,(2×)                       ⍝ Return base string, and check superstrings (,⍨bs)
     }
     FindBaseStrings    ⍝ Common base strings of ⍺ and ⍵
 }