From 0d7e7fab55cc420bb8daa29e1a83a8577470ae21 Mon Sep 17 00:00:00 2001 From: Alexander Vinober Date: Mon, 21 Nov 2016 10:36:27 +0300 Subject: [PATCH] pair of gloves kata --- katas/pair-of-gloves/pair-of-gloves.js | 3 +++ katas/pair-of-gloves/pair-of-gloves_test.js | 7 ++++++ katas/pair-of-gloves/readme.md | 25 +++++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 katas/pair-of-gloves/pair-of-gloves.js create mode 100644 katas/pair-of-gloves/pair-of-gloves_test.js create mode 100644 katas/pair-of-gloves/readme.md diff --git a/katas/pair-of-gloves/pair-of-gloves.js b/katas/pair-of-gloves/pair-of-gloves.js new file mode 100644 index 0000000..5b5d92c --- /dev/null +++ b/katas/pair-of-gloves/pair-of-gloves.js @@ -0,0 +1,3 @@ +function numberOfPairs(gloves) { + //My hands are freezing +} \ No newline at end of file diff --git a/katas/pair-of-gloves/pair-of-gloves_test.js b/katas/pair-of-gloves/pair-of-gloves_test.js new file mode 100644 index 0000000..958e93d --- /dev/null +++ b/katas/pair-of-gloves/pair-of-gloves_test.js @@ -0,0 +1,7 @@ +describe('pair of gloves', function() { + it('should return number of pairs of gloves', function() { + expect(numberOfPairs(['red', 'red'])).toEqual(1); + expect(numberOfPairs(['red', 'green', 'blue'])).toEqual(0); + expect(numberOfPairs(['gray','black','purple','purple','gray','black'])).toEqual(3); + }); +}); diff --git a/katas/pair-of-gloves/readme.md b/katas/pair-of-gloves/readme.md new file mode 100644 index 0000000..976fae7 --- /dev/null +++ b/katas/pair-of-gloves/readme.md @@ -0,0 +1,25 @@ +####Description: + +Winter is comming, you must prepare your ski holidays. The objective of this kata is to determine the number of pair of gloves you can constitute from the gloves you have in your drawer. + +A pair of gloves is constituted of two gloves of the same color. + +You are given an array containing the color of each glove. + +You must return the number of pair you can constitute. + +You must not change the input array. + +####Example: + +```js +numberOfPairs(['red', 'red']) //returns 2 +numberOfPairs(['red', 'green', 'blue']) //returns 0 +numberOfPairs(['gray','black','purple','purple','gray','black']) //returns 3 +``` + +See [tests in pair-of-gloves_test.js](https://github.com/AlexVvx/code-wars/blob/master/katas/pair-of-gloves/pair-of-gloves_test.js) + +#####[Original Kata](https://www.codewars.com/kata/pair-of-gloves) + +Good luck