Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: j1n3l0/codewars
base: be499b197b
...
head fork: j1n3l0/codewars
compare: 53deae82e0
  • 3 commits
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 46 additions and 0 deletions.
  1. +46 −0 test/codewars-test.coffee
View
46 test/codewars-test.coffee
@@ -49,3 +49,49 @@ describe "RGB To Hex Conversion", ->
it "should convert all valid decimal to hexadecimal numbers", ->
expect(solution 148, 0, 211).to.eql("9400D3")
+
+#
+# http://www.codewars.com/dojo/katas/51e704f2d8dbace389000279
+describe 'Arrays Similar', ->
+ solution = (a, b) ->
+ if a.length is b.length
+ a = a.sort()
+ b = b.sort()
+ [ 0 .. a.length - 1 ].every((i) -> a[i] is b[i])
+ else
+ false
+
+ describe 'for different sized arrays', ->
+ it 'should always return false', ->
+ expect(solution [], [1]).to.eql(false)
+
+ describe 'for same sized arrays', ->
+ it 'should be true for empty arrays', ->
+ expect(solution [], []).to.eql(true)
+
+ it 'should be false for single elment arrays with different elements', ->
+ expect(solution [1], [2]).to.eql(false)
+
+ it 'should be order independent', ->
+ expect(solution [1,2], [2,1]).to.eql(true)
+
+#
+# http://www.codewars.com/dojo/katas/51675d17e0c1bed195000001
+describe 'Largest 5 digit number in a series', ->
+ partition = (coll, n) ->
+ (coll.slice(v, v + n) for _, v in coll).filter((x) -> x.length is n)
+
+ solution = (coll) ->
+ partition(coll, 2).map((n) -> parseInt n).sort((a,b) -> a < b)[0]
+
+ it 'should be 91 for 283910', ->
+ expect(solution '283910').to.equals(91)
+
+#
+# http://www.codewars.com/dojo/katas/515e271a311df0350d00000f
+describe 'Square(n) Sum', ->
+ solution = (coll) ->
+ coll.map((n) -> n * n).reduce((acc, x) -> acc + x)
+
+ it 'should return 9 for [1, 2, 2]', ->
+ expect(solution [1, 2, 2]).to.equal(9)

No commit comments for this range

Something went wrong with that request. Please try again.