Ad
  • Custom User Avatar

    Rust translation

    Note: it changes the description a bit (specifically for Rust).

  • Custom User Avatar

    Now, the function prototype in the solution setup is incorrect.

  • Custom User Avatar
  • Custom User Avatar

    It's a docstring. You can run help(mirror_fold) to see this text.

  • Custom User Avatar
  • Custom User Avatar

    After some more fiddling, I've got that exactly floating point formula

    price += ceil(rental / people_left * days_span)
    

    produces the expected result. Changing the order, like first multiplying and then dividing, gives a totally different outcome.

    And no, this is not a spoiler, this is an absolutely needed information to complete this kata - you should not just round up, but do calculations in double-precision floating point in this specific order. With the current tests, it should be in the description (or tests should be changed).

  • Custom User Avatar

    Can anyone explain HOW THE HELL should numbers be rounded? I got 5 medium tests failing, everything else (125 tests) fine. I printed data and got this:

    {770: 91453, 1155: 139009, 2387: 297527, 3003: 380232, 6237: 834168, 8470: 1162526, 9086: 1257637, 9779: 1370268, 10010: 1409898, 12320: 1829503, 12859: 1933530, 14938: 2361527, 15862: 2565335, 16016: 2601916, 18172: 3156727, 18557: 3264807, 21714: 4239689, 21945: 4318948, 22715: 4616168, 23177: 4819976, 24255: 5374787, 24871: 5755229, 25795: 6468557, 26026: 6825221, 27412: 11105189} should equal {770: 91453, 1155: 139009, 2387: 297527, 3003: 380232, 6237: 834169, 8470: 1162527, 9086: 1257638, 9779: 1370269, 10010: 1409899, 12320: 1829504, 12859: 1933531, 14938: 2361528, 15862: 2565336, 16016: 2601917, 18172: 3156728, 18557: 3264809, 21714: 4239691, 21945: 4318950, 22715: 4616170, 23177: 4819978, 24255: 5374789, 24871: 5755231, 25795: 6468559, 26026: 6825223, 27412: 11105191}
    

    The difference is in day 6237. The corresponding log:

    On day = 770, 1 leaves paying 91453 (rounded from 770*3088/26=1188880/13)
    On day = 1155, 1 leaves paying 139009 (rounded from 385*3088/25=237776/5)
    On day = 2387, 1 leaves paying 297527 (rounded from 1232*3088/24=475552/3)
    On day = 3003, 1 leaves paying 380232 (rounded from 616*3088/23=1902208/23)
    On day = 6237, 1 leaves paying 834168 (rounded from 3234*3088/22=453936)
    

    In expected result, day 6237 should be 834169.
    Can someone open my eyes and show how 380232 + 3234 * 3088 / 22 (which is 834168) is 834169 after rounding up? What kind of black magic is expected to be used?

  • Custom User Avatar
  • Custom User Avatar

    C++ test fails:

    Expected: equal to 0.026314
    Actual: 0.026314
    

    Really?

  • Custom User Avatar
  • Custom User Avatar

    Changed the random speed to positive, optimized solution to nonsense, removed all unneeded high-level abstractions, and run rustfmt over all the code.

    Good enough now?

  • Custom User Avatar

    fixed RPMs

  • Custom User Avatar

    The comment is obvously AI-generated.

    I usually use different approaches in solution and reference to avoid mistakes; and I don't think the solution should be perfect, it should just work.

    Positive RPMs in random tests - yes, I will fix it. I just copied the formula from the original code.

  • Custom User Avatar
  • Custom User Avatar

    I mean a new kata with an alike task but harder test cases. Like 3 connected gears will never rotate.

  • Loading more items...