Ad
  • Custom User Avatar

    Hey what data type is returned such that === makes the solution not work.

  • Custom User Avatar

    Probably a typo, but your fixed test should be:

    (is (= (head [5 1]) 5))

  • Custom User Avatar

    Didn't write the Clojure variant, but at this point one cannot change the test cases anymore.

  • Default User Avatar

    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))
    )

  • Custom User Avatar

    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.

  • Custom User Avatar

    Im using javascript I provided What the error is Showing me . It's Expeacting the wrong tail to be returNed

  • Custom User Avatar

    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.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    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))
    )

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    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.

  • Default User Avatar

    @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?

  • Custom User Avatar

    Which top solution did you try (JS or CoffeeScript)? It's working fine when I try it.

  • Default User Avatar

    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 ==.