Created
August 16, 2013 16:16
-
-
Save grondilu/6251288 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sub longest_increasing_subsequence(@d) { | |
| my @l = [[].item]; | |
| for ^@d -> $i { | |
| @l.push: [ max(:by(*.elems), grep { .[*-1] < @d[$i] }, @l[0..$i]).list, @d[$i] ].item; | |
| } | |
| return max :by(*.elems), @l; | |
| } | |
| say .perl given longest_increasing_subsequence <0 8 4 12 2 10 6 14 1 9 5 13 3 11 7 15>».Int; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment