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.
Hi Zoltan, nice Kata idea, but there are some problems: the tests should be 'testAssertEquals' and what the code has to return written out in full, or at least 'NO!' should be replaced by 'NO WAY!' in order for 'testAssertContains' to work with the requested return for a negative.
I think something is wrong with your test code, also, as when I try to test I get the error 'Journey is not defined'. You should check your code to make sure you've not got Journey instead of 'myJourney' somewhere, perhaps?
The description is hard to read and misleading, e.g. you write
you need to create your own map
but all I need is the two dimensional array that's passed as the first argument.Or you write
each zone will cost you £1 more to cross
which I read as "it costs 2 + 3 + 4 + ... = (n + 2) * (n - 1) / 2 to travel from zone a to zone a + n" but instead it's just "n + 1".The solution setup has unneccessarily an array
stations
and a function callmyJourney(stations, 5, "Dalston", "Crystal Palace");
. Remove them.The tests use
assertContains
which IMHO is an invitation to cheating.Better be specific about what you expect, e.g. "return a string 'YES! You can make it! You will have £xxx left on your card.' (where xxx is the amount of credits left after paying for the ride) OR 'NO! Top-up £xxx or more for this journey.' (where xxx is the amount of additional credits needed for the ride)."
Then testing becomes a lot easier.
Also, the random tests are commented out.
Currently this kata looks half-baked. I suggest you un-publish it and improve it in 'Draft' state or you will get a lot of negative votes.
As mentioned below, it's a duplicate.
Also, trailing new line is not specified.
Random testing not implemented. But really, don't bother. Too simple and too probably a duplicate.