diff --git a/.travis.yml b/.travis.yml index f52bbce..c43f53f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,17 @@ language: node_js node_js: - - "6" + - "8" +#Travis-CI Caching +cache: + directories: + -node_modules addons: chrome: stable -before_script: - - "export DISPLAY=:99.0" - - "sh -e /etc/init.d/xvfb start" - - sleep 3 # give xvfb some time to start +dist: xenial +services: + -xvfb before_install: npm install karma-cli -g \ No newline at end of file diff --git a/quz/quz.js b/quz/quz.js index 624e7de..0c619a5 100755 --- a/quz/quz.js +++ b/quz/quz.js @@ -9,6 +9,17 @@ */ function dcate(A, B) { /** Fill in here **/ + let len = A.toString().match(/\d/g).length, + p = A, + i; + for(i = 0; i < len; i++) { + if(p.tail !== null) { + p = p.tail; + } else { + p.tail = B; + } + } + return A; } /** @@ -24,4 +35,27 @@ function dcate(A, B) { */ function sub(L, start, len) { /** Fill in here **/ + let length = L.toString().match(/\d/g).length, + p = l, + R = { + head: null, + tail: null + }, + s = R, + i = 0; + while(i < length && i <= start + len - 1) { + if(i === start) { + R.head = p.head; + } else if(i > start) { + s.tail = { + head: p.head, + tail: null + } + s = s.tail; + } + p.tail && (p = p.tail); + i++; + } + R.toString = L.toString; + return R; }