Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,21 @@
|
|||
lcs←{
|
||||
⎕IO←0
|
||||
betterof←{⊃(</+/¨⍺ ⍵)⌽⍺ ⍵} ⍝ better of 2 selections
|
||||
cmbn←{↑,⊃∘.,/(⊂⊂⍬),⍵} ⍝ combine lists
|
||||
rr←{∧/↑>/1 ¯1↓[1]¨⊂⍵} ⍝ rising rows
|
||||
hmrr←{∨/(rr ⍵)∧∧/⍵=⌈\⍵} ⍝ has monotonically rising rows
|
||||
rnbc←{{⍵/⍳⍴⍵}¨↓[0]×⍵} ⍝ row numbers by column
|
||||
valid←hmrr∘cmbn∘rnbc ⍝ any valid solutions?
|
||||
a w←(</⊃∘⍴¨⍺ ⍵)⌽⍺ ⍵ ⍝ longest first
|
||||
matches←a∘.=w
|
||||
aps←{⍵[;⍒+⌿⍵]}∘{(⍵/2)⊤⍳2*⍵} ⍝ all possible subsequences
|
||||
swps←{⍵/⍨∧⌿~(~∨⌿⍺)⌿⍵} ⍝ subsequences with possible solns
|
||||
sstt←matches swps aps⊃⍴w ⍝ subsequences to try
|
||||
w/⍨{
|
||||
⍺←0⍴⍨⊃⍴⍵ ⍝ initial selection
|
||||
(+/⍺)≥+/⍵[;0]:⍺ ⍝ no scope to improve
|
||||
this←⍺ betterof{⍵×valid ⍵/matches}⍵[;0] ⍝ try to improve
|
||||
1=1⊃⍴⍵:this ⍝ nothing left to try
|
||||
this ∇ 1↓[1]⍵ ⍝ keep looking
|
||||
}sstt
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue