Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Hey what data type is returned such that === makes the solution not work.
Probably a typo, but your fixed test should be:
(is (= (head [5 1]) 5))
Didn't write the Clojure variant, but at this point one cannot change the test cases anymore.
The tests trivially pass as written. They should look like this (note I've added an =)
(deftest string-to-number-test
(is (= (string-to-number "1234") 1234))
(is (= (string-to-number "605") 605))
(is (= (string-to-number "1405") 1405))
(is (= (string-to-number "-7") -7))
)
The clojure tests shouldn't differ between the two datasctructures. I realise the difference, but this is a kata simply to illustrate the concept, rather than implement it in a type-safe, complete way.
Im using javascript I provided What the error is Showing me . It's Expeacting the wrong tail to be returNed
All tests are random, so I can't help you, especially since you're not telling me what language you're using. You probably need to change your solution.
This comment is hidden because it contains spoiler information about the solution
The example Clojure tests are misleading. They will pass with the most trivial implementation (as long as the functions are defined).
(deftest example-tests
(is (head [5 1]) 6)
(is (tail [1]) [])
(is (init [1 5 7 9]) [1 5 7])
(is (last_ [7 2]) 2)
)
They should be
(deftest example-tests-fixed
(is (= (head [5 1]) 6))
(is (= (tail [1]) []))
(is (= (init [1 5 7 9]) [1 5 7]))
(is (= (last_ [7 2]) 2))
)
This comment is hidden because it contains spoiler information about the solution
Update: I've confirmed that this is solvable in JS. However, I still don't see how this can be solved in Coffeescript due to differences in the language. I'll explain more in my next post and mark it as a spoiler.
@osuushi Thanks for your question. I tried the Coffeescript solution. I also double checked it was not working at http://coffeescript.org/. I must be missing something! Can I send you a gist of what I tried?
Which top solution did you try (JS or CoffeeScript)? It's working fine when I try it.
I'm so confused. I struggled with this for a long time and finally gave up and looked at the answers. I must be missing something, but the solutions don't even work for me! I've copy/pasted in the top solution and the first test expectation and it fails. I don't want to say too much, but the failing assertion concerns ==.