Ad
  • Custom User Avatar

    Approved by author secretly

  • Custom User Avatar

    I looked at your solution. I am rather sure that the problem comes from your division (division introduces an added error, error "multiplied" by a multiplication) in your calculation of "newAvg". I re-wrote that line and then your solution passes every time.

  • Custom User Avatar

    Thanks for your work! I see that you finally passed the kata. The description says:

    The function new_avg(arr, navg) should return the expected donation (rounded up to the next integer) that will permit to reach the average navg.

    The answer must be an integer so I don't see a reason to use a tolerance.
    To get "navg = 115053.00000000001" I suppose that in a first approach you didn't round up(?).

  • Custom User Avatar

    Sorry I didn't understand your post.
    When I wrote: Substrings in the input string are separated by , or ," I didn't mean that in each language there would be the two types of separator; I meant that the types could be one or the other depending on the language. It happens that Kotlin has the first type of separator and Swift has the other type. Anyway with a regex (as yo did) the difference is not a problem. I added that sentence after a post from ByteEater that you can see below.

  • Custom User Avatar

    Substrings in the input string are separated by ", "

    They are ... (comma + white space). Maybe you didn't see the white space after the comma in description?
    Look at "Sample tests" and you will see.

    assertEquals(
                "Range: 01|01|18 Average: 01|38|05 Median: 01|32|34",
                Stat.stat("01|15|59, 1|47|16, 01|17|20, 1|32|34, 2|17|17")
            )
    

    Before posting issues look at the top of the page to see how many people passed the kata in your language. If there were problems somebody would have said them before you. Cheers and good luck!