Anonymous user
Longest increasing subsequence: Difference between revisions
m
→{{header|Clojure}}: {{out}}
m ({{out}}) |
m (→{{header|Clojure}}: {{out}}) |
||
Line 159:
=={{header|Clojure}}==
Implementation using the Patience Sort approach.
The combination is done using ''cons'', so what gets put on a pile is a list -- a descending subsequence.
<lang Clojure>(defn place [piles card]
Line 173 ⟶ 175:
(println (a-longest [3 2 6 4 5 1]))
(println (a-longest [0 8 4 12 2 10 6 14 1 9 5 13 3 11 7 15]))</lang>
{{out}}
<lang>(2 4 5)
(0 2 6 9 11 15)</lang>
|