Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- assert = require "assert"
- {meld} = lis = require "../lis"
- describe "Longest Increasing Subset", ->
- [
- [[], []]
- [[1], [1]]
- [[1,2,3,4,5], [1,2,3,4,5]]
- [[5,4,3,2,1], [1]]
- [[10, 11, 1, 2, 13, 12, 14], [1, 2, 12, 14]]
- [[9, 10, 11, 1, 2, 13, 12], [9, 10, 11, 12]] # !!
- [[1, 9, 4, 5, 6], [1, 4, 5, 6]]
- [[10, 5, 6, 1, 2, 4], [1, 2, 4]]
- [[10, 5, 6, 1, 2, 4], [1, 2, 4]]
- [[15, 27, 14, 38, 26, 55, 46, 65, 85], [15, 27, 38, 55, 65, 85]]
- [[0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15], [0, 2, 6, 9, 11, 15]]
- [[10, 5, 6, 7, 99, 1, 2, 4], [5, 6, 7, 99]]
- [[10, 20, 30, 40, 50, 60, 70, 80, 21, 22, 23, 24, 25], [10, 20, 30, 40, 50, 60, 70, 80]]
- ].forEach ([input, output]) ->
- it "[#{input}] -> [#{output}]", ->
- assert.deepEqual lis(input), output
- describe "Meld", ->
- [
- [[], [], []]
- [[1], [], [1]]
- [[1], [2], [1, 2]]
- [[2], [1], [1]]
- [[9, 10, 11], [1, 2, 12], [9, 10, 11, 12]]
- ].forEach ([i1, i2, o]) ->
- it "[#{i1}], [#{i2}] -> [#{o}]", ->
- meld(i1, i2)
- assert.deepEqual i1, o
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement