SHARE
TWEET

Untitled

a guest May 18th, 2019 93 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. assert = require "assert"
  2.  
  3. {meld} = lis = require "../lis"
  4.  
  5. describe "Longest Increasing Subset", ->
  6.   [
  7.     [[], []]
  8.     [[1], [1]]
  9.     [[1,2,3,4,5], [1,2,3,4,5]]
  10.     [[5,4,3,2,1], [1]]
  11.     [[10, 11, 1, 2, 13, 12, 14], [1, 2, 12, 14]]
  12.     [[9, 10, 11, 1, 2, 13, 12], [9, 10, 11, 12]] # !!
  13.     [[1, 9, 4, 5, 6], [1, 4, 5, 6]]
  14.     [[10, 5, 6, 1, 2, 4], [1, 2, 4]]
  15.     [[10, 5, 6, 1, 2, 4], [1, 2, 4]]
  16.     [[15, 27, 14, 38, 26, 55, 46, 65, 85], [15, 27, 38, 55, 65, 85]]
  17.     [[0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15], [0, 2, 6, 9, 11, 15]]
  18.     [[10, 5, 6, 7, 99, 1, 2, 4], [5, 6, 7, 99]]
  19.     [[10, 20, 30, 40, 50, 60, 70, 80, 21, 22, 23, 24, 25], [10, 20, 30, 40, 50, 60, 70, 80]]
  20.   ].forEach ([input, output]) ->
  21.     it "[#{input}] -> [#{output}]", ->
  22.       assert.deepEqual lis(input), output
  23.  
  24. describe "Meld", ->
  25.   [
  26.     [[], [], []]
  27.     [[1], [], [1]]
  28.     [[1], [2], [1, 2]]
  29.     [[2], [1], [1]]
  30.     [[9, 10, 11], [1, 2, 12], [9, 10, 11, 12]]
  31.   ].forEach ([i1, i2, o]) ->
  32.     it "[#{i1}], [#{i2}] -> [#{o}]", ->
  33.       meld(i1, i2)
  34.       assert.deepEqual i1, o
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top