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.
Approved some time ago
I did this kata in Kotlin. And I would suggest to remove this kata from the Kotlin katas or modify it.
Kotlin goes a great length to be a typesafe language, to reduce an array to Any so that it is possible to have different types in this array, should be prevented at all cost (in Kotlin).
This kata is a level 7 kata and is done from a lot of "Kotlin-Beginners", they could think that this is a good practise (in Kotlin).
Yes, there are other languages, in which you can put everything in an array, but you should not do this in Kotlin.
Instead of using an Array of Any I would suggest to use an Array of String as input.
my code passes in all test cases using intelliJ and fails here (Kotlin)
Something's wrong :(
This comment is hidden because it contains spoiler information about the solution
Added an example to the kata's description.
No that's the thing - these 2 given test cases are confusing precisely because they are both compatible with the "other" interpretation (since they are of length <= 4):
interpretation 1: "if len >= 2, take capped cost as cost of exactly 2 journeys"
interpretation 2: "group into blocks of 2"
Applied to the given examples:
[56, 93, 243]
interpretation 1: len 3 >= 2 -> capped at 2 journeys @ 1.50 = 3.00
interpretation 2: {56,93}, {243} -> 2 blocks @ 1.50 = 3.00
[386, 56, 1, 876]
interpretation 1: len 4 >= 2 -> capped at 2 journeys @ 1.50 = 3.00
interpretation 2: {386,56}, {1,876} -> 2 blocks @ 1.50 = 3.00
To illustrate the behaviour difference, there could be a case with more than 4 contiguous bus journeys, since for 5,6,7... journeys the difference begins to appear.
Hmm fair enough then; I edited my comments therefore - I'm still not sure it's clear english, why not say something like "buy one get one free" for contiguous bus journeys. Or have such a test case in description (you only encounter this behavior in random tests in Python at least). Thanks for the update
And that's exactly what it means:
Each set of two, you pay only one.
Now that I've seen the code of OP, it's overly complicated. The solution is really simple.
Update - ok I solved it from studying the tests, what the kata wants is as follows:
[b, b, b, b, b, b, b]
->bb + bb + bb + b
= pay for 4 bus journeys.see below -
Which language, which flaws?
To the author of this challenge
As per the other comments on this kata, I would be very grateful if you could please review the programming and mechanics of this challenge to ensure that everything is definitely correct
To anyone attempting this challenge
My considered advice is to move on to another challenge as there appears to be flaws in the programming and mechanics of this challenge
I would suggest to print some data that would help you make sure what the issue is. For example the groups and prices.
Might be a minor error in the formulas or a rounding error in the answer.
Ah I see, Thanks!
Hi, it's not a kata issue, you just need to return the value, not print.
Loading more items...