Ad
  • Custom User Avatar

    Your solution is сoncise and understandable at the same time. Well done.

  • Custom User Avatar

    This kata made me RTFM and learn about classes and dunders in Python :D

  • Custom User Avatar

    it just looks funny to me :)

  • Custom User Avatar
  • Custom User Avatar

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

  • Custom User Avatar

    Don't know what're you talking about, kata seems fine for me. I would add "don't use strings" as an additional requirement (That is what people do in similar python katas)

  • Custom User Avatar

    Don't know what you're talking about, kata seems good enough for me. I would add "don't use strings" as they do for similar python katas :)

  • Custom User Avatar

    IMO, casts are a red flag for bad design (that's also why the syntax is so ugly), so if you can get rid of one, that's a good idea. It has no runtime impact, indeed.
    I am also not 100% certain about how it works, just that it makes code a little more readable as the functor is defined where it's used, instead of the reader having to look it up.
    But there are really minor points.

  • Custom User Avatar

    Thanks for you comment! I used static cast to explicitly show that it will be int. As far as I know it has no impact during runtime, i.e. check performed only during compilation.
    As for lambda, I use it in C# a lot, but C++ is a mishmash on its own, so this was again for clarity reasons. Besides I don't have a foggiest idea how lamda works in C++ "under the hood" :)

  • Custom User Avatar

    That static cast to int is not required due to the C++ integer promition rules: every arithmetic operation is converted to at least integer size.
    Also, have you considered using a lambda instead of the acumCubes function? Worthwile.
    Other than that: my compliments that you are using algorithms as much as possible! That makes this the first solution I've read that's actually easy to read and comprehend.

  • Custom User Avatar

    In the problem description, it says the answer should be truncated as an int, not rounded. The answer should be 104.

  • Custom User Avatar

    105 is the correct answer to this problem. Do the math by hand, the right answer is 104.8695.

  • Custom User Avatar

    Thanks for your post!

  • Custom User Avatar

    Awesome kata! Thanks g964!

    It seems comparing my own solution against other's makes the biggest difference for me!
    I spend almost equal time to solving AND tracking other solutions!
    And had to tackle std::chrono to find out if there are any performance boost at all :D

  • Custom User Avatar

    Hi!
    Put character into single quotation marks, like this '*'.
    Then compiler will count it as single char.
    Double quotation marks, like this "*", means that you have a C-string char* containing 1 symbol.

  • Loading more items...