Ad
  • Custom User Avatar

    Approved some time ago

  • Default User Avatar

    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.

  • Custom User Avatar

    my code passes in all test cases using intelliJ and fails here (Kotlin)
    Something's wrong :(

  • Default User Avatar

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

  • Custom User Avatar

    Added an example to the kata's description.

  • Default User Avatar

    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]

    1. interpretation 1: len 3 >= 2 -> capped at 2 journeys @ 1.50 = 3.00

    2. interpretation 2: {56,93}, {243} -> 2 blocks @ 1.50 = 3.00

    [386, 56, 1, 876]

    1. interpretation 1: len 4 >= 2 -> capped at 2 journeys @ 1.50 = 3.00

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

  • Default User Avatar

    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 :+1:

  • Custom User Avatar

    If there are 2 or more adjacent bus journeys, the bus fare is capped for sets of two adjacent buses and calculated as one bus fare for each set.

    And that's exactly what it means:

    [b, b, b, b, b, b, b] -> bb + bb + bb + b = pay for 4 bus journeys.

    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.

  • Default User Avatar

    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.

  • Default User Avatar
  • Custom User Avatar

    Which language, which flaws?

  • Default User Avatar

    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

  • Custom User Avatar

    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.

  • Default User Avatar

    Ah I see, Thanks!

  • Default User Avatar

    Hi, it's not a kata issue, you just need to return the value, not print.

  • Loading more items...