function kumite(arr) { var copy = [...arr]; for(var i=0; i<copy.length-1; i++){ if(copy[i] == copy[i+1]){ for(var j=i+1; copy[j] == copy[i]; j++); copy.splice(i, j-i); i--; } } return copy; }
- function kumite(arr) {
return [];- var copy = [...arr];
- for(var i=0; i<copy.length-1; i++){
- if(copy[i] == copy[i+1]){
- for(var j=i+1; copy[j] == copy[i]; j++);
- copy.splice(i, j-i);
- i--;
- }
- }
- return copy;
- }
const expect = require("chai").expect; describe("Solution", function() { it("should get [1, 3, 4, 9, 5, 3] when given [1, 3, 2, 2, 2, 4, 7, 7, 9, 5, 3]", function() { const result = kumite([1, 3, 2, 2, 2, 4, 7, 7, 9, 5, 3]); expect(result).to.deep.equal([1, 3, 4, 9, 5, 3]); }); it("should get [] when given [1, 1, 2, 2, 2, 99, 99]", function() { const result = kumite([1, 1, 2, 2, 2, 99, 99]); expect(result).to.deep.equal([]); }); it("should get [] when given [6, 6, 6]", function() { const result = kumite([6, 6, 6]); expect(result).to.deep.equal([]); }); it("should get [1024] when given [1024]", function() { const result = kumite([1024]); expect(result).to.deep.equal([1024]); }); it("should get [] when given []", function() { const result = kumite([]); expect(result).to.deep.equal([]); }); it("should get [1, 2, 3, 4, 5, 6, 7] when given [1, 2, 3, 4, 5, 6, 7]", function() { const result = kumite([1, 2, 3, 4, 5, 6, 7]); expect(result).to.deep.equal([1, 2, 3, 4, 5, 6, 7]); }); it("should get [12, 3, 2, 8, 67, 98, 12, 23, 45, 98] when given [12, 4, 7, 7, 3, 2, 1, 1, 1, 8, 67, 98, 45, 45, 12, 23, 45, 98, 120, 120, 120]", function() { const result = kumite([12, 4, 7, 7, 3, 2, 1, 1, 1, 8, 67, 98, 45, 45, 12, 23, 45, 98, 120, 120, 120]); expect(result).to.deep.equal([12, 4, 3, 2, 8, 67, 98, 12, 23, 45, 98]); }); });
- const expect = require("chai").expect;
- describe("Solution", function() {
// it("should get [1, 3, 4, 9, 5, 3] when given [1, 3, 2, 2, 2, 4, 7, 7, 9, 5, 3]", function() {// const result = kumite([1, 3, 2, 2, 2, 4, 7, 7, 9, 5, 3]);// expect(result).to.deep.equal([1, 3, 4, 9, 5, 3]);// });- it("should get [1, 3, 4, 9, 5, 3] when given [1, 3, 2, 2, 2, 4, 7, 7, 9, 5, 3]", function() {
- const result = kumite([1, 3, 2, 2, 2, 4, 7, 7, 9, 5, 3]);
- expect(result).to.deep.equal([1, 3, 4, 9, 5, 3]);
- });
- it("should get [] when given [1, 1, 2, 2, 2, 99, 99]", function() {
- const result = kumite([1, 1, 2, 2, 2, 99, 99]);
- expect(result).to.deep.equal([]);
- });
- it("should get [] when given [6, 6, 6]", function() {
- const result = kumite([6, 6, 6]);
- expect(result).to.deep.equal([]);
- });
- it("should get [1024] when given [1024]", function() {
- const result = kumite([1024]);
- expect(result).to.deep.equal([1024]);
- });
- it("should get [] when given []", function() {
- const result = kumite([]);
- expect(result).to.deep.equal([]);
- });
- it("should get [1, 2, 3, 4, 5, 6, 7] when given [1, 2, 3, 4, 5, 6, 7]", function() {
- const result = kumite([1, 2, 3, 4, 5, 6, 7]);
- expect(result).to.deep.equal([1, 2, 3, 4, 5, 6, 7]);
- });
- it("should get [12, 3, 2, 8, 67, 98, 12, 23, 45, 98] when given [12, 4, 7, 7, 3, 2, 1, 1, 1, 8, 67, 98, 45, 45, 12, 23, 45, 98, 120, 120, 120]", function() {
- const result = kumite([12, 4, 7, 7, 3, 2, 1, 1, 1, 8, 67, 98, 45, 45, 12, 23, 45, 98, 120, 120, 120]);
- expect(result).to.deep.equal([12, 4, 3, 2, 8, 67, 98, 12, 23, 45, 98]);
- });
- });