diff --git a/solutions/116.js b/solutions/116.js new file mode 100644 index 0000000..ca5083b --- /dev/null +++ b/solutions/116.js @@ -0,0 +1,21 @@ +// flatten the array +// +const solution = (arr) => { + if (arr.length === 0) { + return arr; + } + let elem = arr.shift(); + if (elem.length) { + elem.forEach((elem) => { + arr.push(elem); + }); + solution(arr); + } else { + solution(arr).push(elem); + } + return arr; +}; + +module.exports = { + solution: solution, +}; diff --git a/solutions/13.js b/solutions/13.js index 65dc514..0940901 100644 --- a/solutions/13.js +++ b/solutions/13.js @@ -1,3 +1,16 @@ +//Rahul Kalra +//Checking to see if the string is palindrome +const solution2 = (palindromeInput) =>{ + let reverse = ""; + for(let i = palindromeInput.length - 1; i >= 0; i--){ + reverse += palindromeInput[i]; + } + if(reverse === palindromeInput){ + return true; + } + return false; +}; + // vdewinter // Return true if input string is a palindrome @@ -15,4 +28,6 @@ const solution = (str) => { module.exports = { solution, + solution2 }; + diff --git a/solutions/15.js b/solutions/15.js index 981b075..5f1825f 100644 --- a/solutions/15.js +++ b/solutions/15.js @@ -9,6 +9,18 @@ const solution = (fullString, subString) => { return fullString.includes(subString); }; +// Colin Xie +const solution1 = (fullString, subString) => { + for(let i = 0; i < fullString.length; i++){ + let subFull = fullString.substring(i,i + subString.length); + if(subFull === subString){ + return true; + } + } + return false; +}; + module.exports = { solution, + solution1, }; diff --git a/solutions/21.js b/solutions/21.js new file mode 100644 index 0000000..1a4a6a4 --- /dev/null +++ b/solutions/21.js @@ -0,0 +1,35 @@ +// Rahul Kalra +// Return array of largest 3 values in descending order from a given array + +const max = (array) =>{ + let max = array[0]; + for(let i = 0; i < array.length; i++){ + if(max <= array[i+1]){ + max = array[i+1]; + } + } + return max; +}; + +const removeNum = (array, max) =>{ + let newArray = []; + for(let i = 0; i < array.length; i++){ + if(!(max === array[i])){ + newArray.push(array[i]); + } + } + return newArray; +}; + +const solution = (array) =>{ + let a = 0; + let newArray = []; + for(let i = 0; i < 3; i++){ + a = max(array);; + array = removeNum(array, a); + newArray.push(a); + } + return [newArray[0], newArray[1], newArray[2]]; +}; + +module.exports = {solution}; diff --git a/solutions/31.js b/solutions/31.js index 4e6a1b3..5282448 100644 --- a/solutions/31.js +++ b/solutions/31.js @@ -3,12 +3,12 @@ // input: ['hi','hello','hola'] // output 'hello' -// Solutions by Colin Xie @ColinX13 - +// Solution by Colin Xie @ColinX13 +// Solution1 by Maricris Bonzo @Seemcat /** * @param {string[]} arr - the array of strings * @return {string} word - the longest word in the array -*/ + */ const solution = (arr) => { let maxLength = 0; let word = 0; @@ -20,6 +20,20 @@ const solution = (arr) => { } return word; }; + +const solution1 = (arr) => { + let big = arr[0]; + let i = 1; + while(i < arr.length){ + if (big.length < arr[i].length){ + big = arr[i]; + } + i++; + }; + return big; +}; + module.exports = { solution, + solution1 }; diff --git a/solutions/32.js b/solutions/32.js new file mode 100644 index 0000000..e363636 --- /dev/null +++ b/solutions/32.js @@ -0,0 +1,23 @@ +//Rahul Kalra +//Finding Singleton + +const solution = (array) =>{ + let data = {}; + let newArray = []; + for(let i = 0; i < array.length; i++){ + if(!(data[array[i]])){ + data[array[i]] = 1; + } + else{ + data[array[i]]++; + } + } + for(let key in data){ + if(data[key] === 1){ + newArray.push(Number(key)); + } + } + return newArray; +}; + +module.exports = {solution}; diff --git a/solutions/34.js b/solutions/34.js index 12c1979..ace606c 100644 --- a/solutions/34.js +++ b/solutions/34.js @@ -1,6 +1,5 @@ // Daniel // Number of repeating elements in an array - const solution = (arr, k) => { let total = 0; for (i=0; i < arr.length; i++) { @@ -9,7 +8,26 @@ const solution = (arr, k) => { } } return total; - }; - module.exports = { - solution, }; + +// Maricris Bonzo +const solution1 = (array, num) => { + let i = 0; + let numOfTimes = 0; + + while (i < array.length){ + if (array[i] === num){ + numOfTimes = numOfTimes + 1; + i++; + } else { + i++; + } + } + return numOfTimes; +}; + +module.exports = { + solution, + solution1 + }; + diff --git a/solutions/56.js b/solutions/56.js index 3d63dc5..a37c3f2 100644 --- a/solutions/56.js +++ b/solutions/56.js @@ -27,7 +27,24 @@ const solution = (arr, total) => { return acc; }, total); }; +// return min number of coins +// daniel s. +const solution2 = (arr, value) => { + if (value === 0) { + return 0; + }; + let currentMin = value; + arr.forEach((coin)=> { + let childCoins = 0; + if (value - coin > 0) { + childCoins = solution2(arr, value - coin); + } + currentMin = Math.min(currentMin, childCoins); + }); + return currentMin + 1; +}; module.exports = { solution, + solution2, }; diff --git a/solutions/58.js b/solutions/58.js new file mode 100644 index 0000000..3b94e48 --- /dev/null +++ b/solutions/58.js @@ -0,0 +1,61 @@ +// Max Fun Problem +// Return an array of employees that creates the maximum fun +// Input: Employee object +// Output: [Employee objects] + +// Solution by Yoo Jin + +class Employee { + constructor(funVal, staffArray=[]) { + this.funVal = funVal; + this.staff = []; + this.addStaff(staffArray); + } + + addStaff(staffArray) { + staffArray.forEach((staff) => { + this.staff.push(staff); + }); + } +} + +/** + * Given an Employee, return an array of employees that creates the maximum fun. + * There is one condition: An Employee cannot be on the guestlist if his direct manager is going to the party. + * @param {Employee} emp - an Employee with fun value and a list of his staff + * @returns {Employee []]} list - Array of employees that creates the maximum fun + */ +const solution = (emp) => { + if(!emp) { + return []; + } + + if(emp.staff.length === 0) { + return [emp]; + } + + let funStaffListWithoutEmp = []; + let funValWithoutEmp = emp.staff.reduce((funVal, staff) => { + let staffList = solution(staff); + funStaffListWithoutEmp = funStaffListWithoutEmp.concat(staffList); + return staffList.reduce((acc, emp) => (acc + emp.funVal), funVal); + }, 0); + + let funValWithEmp = emp.funVal; + let funStaffListWithEmp = [emp]; + emp.staff.forEach((staff) => { + funValWithEmp = staff.staff.reduce((funVal, staff) => { + let staffList = solution(staff); + funStaffListWithEmp = funStaffListWithEmp.concat(staffList); + return staffList.reduce((acc, emp) => (acc + emp.funVal), funVal); + }, funValWithEmp); + }); + + return funValWithoutEmp > funValWithEmp ? + funStaffListWithoutEmp : funStaffListWithEmp; +}; + +module.exports = { + Employee, + solution +}; diff --git a/solutions/61.js b/solutions/61.js index 6a75396..c4a5c19 100644 --- a/solutions/61.js +++ b/solutions/61.js @@ -3,11 +3,11 @@ // Input: 16,24 // Output: 8 -// Solutions by Colin Xie @ColinX13 +// Solution #0 by Colin Xie @ColinX13 +// Solution #1 by Maricris Bonzo @seemcat -/* - * Factor is determined when both remainders of num1 and num2 - * are 0 when factor is divided from them. +/** + * Factor is determined when both remainders of num1 and num2 are 0 when factor is divided from them. * @param num1 - the first number input * @param num2 - the second number input * @return {number} factor - the greatest common factor for num1 and num2 @@ -19,6 +19,48 @@ const solution = (num1, num2) => { } } }; + +const solution1 = (num1, num2) => { + let num1Array = []; + let num2Array = []; + let i = 1; + let j = 1; + + while (i <= num1) { + if (num1%i === 0){ + num1Array.push(i); + i++; + } else { + i++; + } + }; + + while (j <= num2) { + if (num2%j === 0){ + num2Array.push(j); + j++; + } else { + j++; + } + }; + + let k = 0; + let commonNumbers = []; + + while (k < num2Array.length){ + if (num1Array.indexOf(num2Array[k]) === -1){ + k++; + } else { + commonNumbers.push(num2Array[k]); + k++; + }; + }; + + let GCD = Math.max.apply(Math, commonNumbers); + return GCD; +}; + module.exports = { solution, + solution1 }; diff --git a/solutions/8.js b/solutions/8.js index 16d6ed8..9328029 100644 --- a/solutions/8.js +++ b/solutions/8.js @@ -9,6 +9,19 @@ const solution = (string) => { return newString; }; +// Maricris Bonzo: seemcat + +const solution1 = (string) => { + let indexLength = string.length - 1; + let reverseString = ''; + + for(i = 0; i <= indexLength; i++){ + reverseString = string[i] + reverseString; + } + return reverseString; +}; + module.exports = { solution, + solution1 }; diff --git a/solutions/sol18.py b/solutions/sol18.py new file mode 100644 index 0000000..0830897 --- /dev/null +++ b/solutions/sol18.py @@ -0,0 +1,17 @@ +#Himanshu Nachane (@Himanshu1495) +'''return missing number in an input array of consecutively increasing numbers. + +i: [5,6,8,9] +o: 7 +''' + +def missing_num(arr): + first_element = arr[0] + last_element = arr[-1] + new_sum = 0 + for x in range(first_element,last_element+1): + new_sum += x + return new_sum - sum(arr) + + + diff --git a/solutions/sol34.py b/solutions/sol34.py new file mode 100644 index 0000000..ea80e78 --- /dev/null +++ b/solutions/sol34.py @@ -0,0 +1,13 @@ +#Himanshu Nachane (@Himanshu1495) +''' +Input: An array, a number +Output: number of times the number shows up in the array. + +Input: [1,2,2,3], 3 +Output: 1 +''' + +def repeating_element(array,number): + return array.count(number) + +print repeating_element([2,3,4,5,3],3) \ No newline at end of file diff --git a/solutions/yourSolution.js b/solutions/yourSolution.js deleted file mode 100644 index f69d2db..0000000 --- a/solutions/yourSolution.js +++ /dev/null @@ -1,9 +0,0 @@ -// Name -// Problem Description - -const yourSolution = () => { -}; - -module.exports = { - yourSolution, -}; diff --git a/test/11.js b/test/11.js index 69372e9..e5982a2 100644 --- a/test/11.js +++ b/test/11.js @@ -1,6 +1,6 @@ const expect = require('chai').expect; let solution = require('../solutions/11').solution; -// solution = require('./yourSolution').solution; +// solution = require('../yourSolution').solution; describe('repeating elements', () => { it('should return repeating elements of an array', () => { diff --git a/test/116.js b/test/116.js new file mode 100644 index 0000000..4105932 --- /dev/null +++ b/test/116.js @@ -0,0 +1,21 @@ +const expect = require('chai').expect; +let solution = require('../solutions/116.js').solution; + +describe('flatten the array', () => { + it('test 1 base', () => { + const result = solution([]); + expect(result).to.eql([]); + }); + it('test 2 simple', () => { + const result = solution([1]); + expect(result).to.eql([1]); + }); + it('test 3 hairy', () => { + const result = solution([3, [5, 2, 6], 4]); + expect(result).to.eql([6, 2, 5, 4, 3]); + }); + it('test 4 complex', () => { + const result = solution([10, 4, [2, [1, 3]], 6, 10]); + expect(result).to.eql([3, 1, 2, 10, 6, 4, 10]); + }); +}); diff --git a/test/13.js b/test/13.js index aee0fd3..8c6becd 100644 --- a/test/13.js +++ b/test/13.js @@ -1,12 +1,15 @@ const expect = require('chai').expect; let solution = require('../solutions/13').solution; -// solution = require('./yourSolution').solution; +let solution2 = require('../solutions/13').solution2; +// solution = require('../yourSolution').solution; describe('reverse String', () => { it('should return true if input string is a palindrome', () => { - expect(solution('racecar')).to.equal(true); + expect(solution("racecar")).to.equal(true); + expect(solution2("racecar")).to.equal(true); }); it('should return true if input string is a palindrome', () => { - expect(solution('palindrome')).to.equal(false); - }); + expect(solution("palindrome")).to.equal(false); + expect(solution2("palindrome")).to.equal(false); + }); }); diff --git a/test/15.js b/test/15.js index 26783f7..a962e3b 100644 --- a/test/15.js +++ b/test/15.js @@ -1,16 +1,35 @@ const expect = require('chai').expect; let solution = require('../solutions/15').solution; +let solution1 = require('../solutions/15').solution1; // solution = require('../yourSolution').solution; describe('is substring', () => { it('should return true if second input is a substring of first input', () => { - const result = solution('all your base are belong to us', 'ase ar'); + let result = solution('all your base are belong to us', 'ase ar'); + expect(result).to.equal(true); + result = solution1('all your base are belong to us', 'ase ar'); expect(result).to.equal(true); }); it('should return false is second input is NOT a substring of first input', () => { - const result = solution('i love tacos more than you', 'carne asada'); + let result = solution('i love tacos more than you', 'carne asada'); + expect(result).to.equal(false); + result = solution1('i love tacos more than you', 'carne asada'); + expect(result).to.equal(false); + }); + + it('should return true if second input is a substring of the first input', () => { + let result = solution('ab cd ef g', 'ef'); + expect(result).to.equal(true); + result = solution1('ab cd ef g', 'ef'); + expect(result).to.equal(true); + }); + + it('should return false if second input is NOT a substring of first input', () => { + let result = solution('can', 'cn'); + expect(result).to.equal(false); + result = solution1('can', 'cn'); expect(result).to.equal(false); }); }); diff --git a/test/16.js b/test/16.js index a7c7210..0c02457 100644 --- a/test/16.js +++ b/test/16.js @@ -1,6 +1,6 @@ const expect = require('chai').expect; let solution = require('../solutions/16').solution; -// solution = require('./yourSolution').solution; +// solution = require('../yourSolution').solution; describe('check duplicates', () => { it('should return true since array has duplicates', () => { diff --git a/test/18.py b/test/18.py new file mode 100644 index 0000000..164ffa9 --- /dev/null +++ b/test/18.py @@ -0,0 +1,14 @@ +import sys +sys.path.insert(0,'../solutions/') +from sol18 import missing_num +import unittest + +class MyTest(unittest.TestCase): + def test1(self): + self.assertEqual(missing_num([10,11,12,14,15,16]),13) + def test2(self): + self.assertEqual(missing_num([125,126,128,129,130]),127) + def test3(self): + self.assertEqual(missing_num([1125,1127,1128,1129,1130]),1126) + +unittest.main() diff --git a/test/19.js b/test/19.js index cfc07b6..8a57e65 100644 --- a/test/19.js +++ b/test/19.js @@ -1,6 +1,7 @@ const expect = require('chai').expect; let solution = require('../solutions/19').solution; - +// solution = require('../yourSolution').solution; + describe('Pairs sum to x', () => { it('should return pairs of number that sum to x', () => { const result = solution([1,2,3,4,5], 6); diff --git a/test/21.js b/test/21.js new file mode 100644 index 0000000..68507ea --- /dev/null +++ b/test/21.js @@ -0,0 +1,15 @@ +let expect = require('chai').expect; +let solution = require('../solutions/21').solution; +// solution = require('../yourSolution').solution; + +describe('Return 3 top largest values of an array in a descending order', () =>{ + it('should return 3 top largest values of an array', () =>{ + expect(solution([8,1,4,2,12,6,7,19,2,9])).to.eql([19, 12, 9]); + }); +}); + +describe('Return 3 top largest values of an array in a descending order', () =>{ + it('should return 3 top largest values of an array', () =>{ + expect(solution([-8,-3,-7,-1,-20,-2])).to.eql([-1,-2,-3]); + }); +}); diff --git a/test/31.js b/test/31.js index a3982d2..a7445ea 100644 --- a/test/31.js +++ b/test/31.js @@ -1,6 +1,7 @@ const expect = require('chai').expect; let solution = require('../solutions/31').solution; -// solution = require('./yourSolution').solution; +let solution1 = require('../solutions/31').solution1; +// solution = require('../yourSolution').solution; describe('longest string in an array', () => { it('the longest string in [hi,hello,hola] is hello', () => { @@ -19,4 +20,19 @@ describe('longest string in an array', () => { it('the longest string in [just] is just', () => { expect(solution(['just'])).eql('just'); }); + it('the longest string in [hi,hello,hola] is hello', () => { + expect(solution1(['hi','hello','hola'])).eql('hello'); + }) + it('the longest string in [is, whether, approximately] is approximately', () => { + expect(solution1(['is','whether','approximately'])).eql('approximately'); + }) + it('the longest string in [wait,see,us] is wait', () => { + expect(solution1(['wait','see','us'])).eql('wait'); + }) + it('the longest string in [shout,basic,lead] is shout', () => { + expect(solution1(['shout','basic','lead'])).eql('shout'); + }) + it('the longest string in [just] is just', () => { + expect(solution1(['just'])).eql('just'); + }) }); diff --git a/test/32.js b/test/32.js new file mode 100644 index 0000000..cb99066 --- /dev/null +++ b/test/32.js @@ -0,0 +1,9 @@ +const expect = require('chai').expect; +let solution = require('../solutions/32').solution; +// solution = require('../yourSolution').solution; + +describe('Finding singleton in an array', () =>{ + it('should return singleton in an array', () =>{ + expect(solution([1,2,3,3,1,4])).to.eql([2, 4]); + }); +}); diff --git a/test/34.js b/test/34.js index 49c4865..e2f89c8 100644 --- a/test/34.js +++ b/test/34.js @@ -1,5 +1,6 @@ const expect = require('chai').expect; const solution = require('../solutions/34.js').solution; +const solution1 = require('../solutions/34.js').solution1; // solution = require('../yourSolution').solution; describe('return number of repeating elements', () => { @@ -15,5 +16,18 @@ describe('return number of repeating elements', () => { it('hardest case', () => { expect(solution([5, 5, 3, 2, 3, 2, 5, 5], 5)).to.equal(4); }); + it('simple case', () => { + expect(solution1([2],2)).to.equal(1); + }); + it('hard case', () => { + expect(solution1([3,2],1)).to.equal(0); + }); + it('harder case', () => { + expect(solution1([3,2,3,2],2)).to.equal(2); + }) + it('hardest case', () => { + expect(solution1([5,5,3,2,3,2,5,5],5)).to.equal(4); + }); + }); diff --git a/test/34.py b/test/34.py new file mode 100644 index 0000000..229fd19 --- /dev/null +++ b/test/34.py @@ -0,0 +1,22 @@ +''' +Input: An array, a number +Output: number of times the number shows up in the array. + +Input: [1,2,2,3], 3 +Output: 1 +''' +import sys +sys.path.insert(0,'../solutions/') +from sol34 import repeating_element +import unittest + + +class MyTest(unittest.TestCase): + def test1(self): + self.assertEqual(repeating_element([10,1,12,4,16,16],16),2) + def test2(self): + self.assertEqual(repeating_element([-164,170,61,-164,152,44,16,-164],-164),3) + def test3(self): + self.assertEqual(repeating_element([1340,1456,1452,4546,1667,1237],1667),1) + +unittest.main() diff --git a/test/5.js b/test/5.js index 5bb5cb0..2d98deb 100644 --- a/test/5.js +++ b/test/5.js @@ -1,6 +1,7 @@ const expect = require('chai').expect; let solution = require('../solutions/5').solution; let solution2 = require('../solutions/5').solution2; +// solution = require('../yourSolution').solution; describe('sort arrays', () => { // solution tests diff --git a/test/56.js b/test/56.js index d9e103e..cc2d7e2 100644 --- a/test/56.js +++ b/test/56.js @@ -1,23 +1,29 @@ const expect = require('chai').expect; const solution = require('../solutions/56.js').solution; +const solution2 = require('../solutions/56.js').solution2; // solution = require('../yourSolution').solution; describe('return smallest number of coins required to return the change', () => { it('simplest case [1], total=1', () => { expect(solution([1], 1)).to.equal(1); + expect(solution2([1], 1)).to.equal(1); }); it('simplest case [1,2], total=0', () => { expect(solution([1, 2], 0)).to.equal(0); + expect(solution2([1, 2], 0)).to.equal(0); }); it('simple case [1,2], total=2', () => { expect(solution([1, 2], 2)).to.equal(1); + expect(solution2([1, 2], 2)).to.equal(1); }); it('simple case [1,2], total=4', () => { expect(solution([1, 2], 4)).to.equal(2); + expect(solution2([1, 2], 4)).to.equal(2); }); it('hard case [1,2,3,6,7], total=12', () => { expect(solution([1, 2, 3, 6, 7], 12)).to.equal(2); + expect(solution2([1, 2, 3, 6, 7], 12)).to.equal(2); }); }); diff --git a/test/58.js b/test/58.js new file mode 100644 index 0000000..1d4d2da --- /dev/null +++ b/test/58.js @@ -0,0 +1,26 @@ +const expect = require('chai').expect; +const solution = require('../solutions/58.js').solution; +const Employee = require('../solutions/58.js').Employee; +// solution = require('../yourSolution').solution; + +describe('return an array of employees that creates the max fun', () => { + let emp1 = new Employee(1); + let emp2 = new Employee(5); + let emp3 = new Employee(11); + let emp4 = new Employee(10,[emp1]); + let emp5 = new Employee(2,[emp2,emp3]); + let emp6 = new Employee(4,[emp4,emp5]); + + it('simplest case of one Employee object', () => { + expect(solution(emp1)).to.deep.equal([emp1]); + }); + it('simple case of one Employee with Staff, where Employee has greater fun value', () => { + expect(solution(emp4)).to.deep.equal([emp4]); + }); + it('simple case of one Employee with Staff, where staff have greater fun value', () => { + expect(solution(emp5)).to.deep.equal([emp2,emp3]); + }); + it('hard case of one Employee with many staff', () => { + expect(solution(emp6)).to.deep.equal([emp4,emp2,emp3]); + }); +}); diff --git a/test/59.js b/test/59.js index 126ec12..f336676 100644 --- a/test/59.js +++ b/test/59.js @@ -1,6 +1,6 @@ const expect = require('chai').expect; let solution = require('../solutions/59').solution; -// solution = require('./yourSolution').solution; +// solution = require('../yourSolution').solution; describe('prime numbers', () => { it('1 should not be a prime number', () => { diff --git a/test/6.js b/test/6.js index e0a523c..2b21434 100644 --- a/test/6.js +++ b/test/6.js @@ -1,5 +1,6 @@ const expect = require('chai').expect; const tree = require('../solutions/6'); +// tree = require('../yourSolution'); const Node = tree.node; describe('tree', () => { diff --git a/test/60.js b/test/60.js index 5676880..e27b9a8 100644 --- a/test/60.js +++ b/test/60.js @@ -1,6 +1,6 @@ const expect = require('chai').expect; let solution = require('../solutions/60').solution; -// solution = require('./yourSolution').solution; +// solution = require('../yourSolution').solution; describe('sum of factors', () => { it('sum of the factors of 2 is 3', () => { diff --git a/test/61.js b/test/61.js index e4106ef..b644659 100644 --- a/test/61.js +++ b/test/61.js @@ -1,6 +1,7 @@ const expect = require('chai').expect; let solution = require('../solutions/61').solution; -// solution = require('./yourSolution').solution; +let solution1 = require('../solutions/61').solution1; +// solution = require('../yourSolution').solution; describe('greatest common denominator', () => { it('the gcd for 16 and 24 is 8', () => { @@ -13,12 +14,12 @@ describe('greatest common denominator', () => { expect(solution(50, 60)).eql(10); }); it('the gcd for 40 and 20 is 20', () => { - expect(solution(40, 20)).eql(20); + expect(solution1(40,20)).eql(20); }); it('the gcd for 20 and 40 is 20', () => { - expect(solution(20, 40)).eql(20); + expect(solution1(20,40)).eql(20); }); it('the gcd for 1 and 4 is 1', () => { - expect(solution(1, 4)).eql(1); + expect(solution1(1,4)).eql(1); }); }); diff --git a/test/64.js b/test/64.js index 3a607a6..084f66a 100644 --- a/test/64.js +++ b/test/64.js @@ -1,6 +1,6 @@ const expect = require('chai').expect; let solution = require('../solutions/64').solution; -// solution = require('./yourSolution').solution; +// solution = require('../yourSolution').solution; describe('reverse word order in a sentence', () => { it('should reverse the word order', () => { diff --git a/test/77.js b/test/77.js index 9f924bf..751906e 100644 --- a/test/77.js +++ b/test/77.js @@ -1,5 +1,6 @@ const expect = require('chai').expect; let solution = require('../solutions/77').solution; +// solution = require('../yourSolution').solution; describe('Return the count of vowels and consonants', () =>{ it('should return { vowel: 2, consonant: 4 } for "yellow"', () =>{ diff --git a/test/8.js b/test/8.js index edb956b..fe60932 100644 --- a/test/8.js +++ b/test/8.js @@ -1,6 +1,7 @@ const expect = require('chai').expect; let solution = require('../solutions/8').solution; -solution = require('../yourSolution').solution; +let solution1 = require('../solutions/8').solution1; +// solution = require('../yourSolution').solution; describe('reverse String', () => { it('should reverse a string in reverse', () => { @@ -23,4 +24,25 @@ describe('reverse String', () => { const expected = "welcome emoclew"; expect(solution(actual)).to.equal(expected); }); + it('should reverse a string in reverse', () => { + const actual = "react"; + const expected = "tcaer"; + expect(solution1(actual)).to.equal(expected); + }); + it('should reverse a string in reverse', () => { + const actual = "word"; + const expected = "drow"; + expect(solution1(actual)).to.equal(expected); + }); + it('should reverse a string in reverse', () => { + const actual = "I"; + const expected = "I"; + expect(solution1(actual)).to.equal(expected); + }); + it('should reverse a string in reverse', () => { + const actual = "welcome emoclew"; + const expected = "welcome emoclew"; + expect(solution1(actual)).to.equal(expected); + }); + }); diff --git a/yourSolution.js b/yourSolution.js index 8a4f885..4547eda 100644 --- a/yourSolution.js +++ b/yourSolution.js @@ -1,7 +1,18 @@ -// Name -// Problem Description +// [ProblemTitle] +// [OneLineProblemDescription] +// Input: +// Output: + +// Solution by [yourName] + +/** + * [DetailedDescription] + * @param + * @returns + */ const solution = () => { + return ''; }; module.exports = {