Ad
  • Custom User Avatar

    I believe this is better than sorting, but not sure?

    With n the size of a single word, sorting is O(n * log(n)), whereas counting should be only O(n).

  • Custom User Avatar

    Okay, let me reformulate.

    I know what a Greatest Common Denominator is, and that it's used to reduce a fraction. So I read the title and skimmed through the description and thought "okay, it's just reducing fractions", but then I read the example and it looked like the exact opposite: you start with a reduced fraction and arbitrarily unreduce it to a bigger fraction?? That's what I meant by "it doesn't make any sense". I should have added "to me", because missing that information, the exercise felt like nonsense. So I read the sample tests, and the description, again and again, but D is quite large and I didn't notice it was the same.

    Now, this is just my experience, and yes I am probably to blame for sticking with my initial assumption and failing to notice the subtlety of the description, but reading the Discourse here I'm not the only one to find this description confusing. And indeed -- please don't take it personally but -- I've read clearer descriptions.

    So, to sum it up:

    • "Common Denominators" doesn't help: it only takes 2 integers to have many common denominators. Plus, D is actually a Least Common Multiplier, not a common denominator.
    • Examples don't necessarily make it clearer when you don't know what to look for. Lots of numbers aren't what the human eye is best at parsing.
    • The many syntaxes for all the languages don't help either.

    I eventually realised my mistake and solved the Kata, so it's all the same to me, but I'm thinking about the people that'll come after me.

    I'm not asking for much. Just adding something like the following would make it clearer imo:

    You have to return a list of rationals that all share the same denominator D such that ...

  • Custom User Avatar

    Please reword the description to make it clear that D should be the same for all elements.

    Otherwise it doesn't make any sense and I spent way to too long figuring this out.

  • Custom User Avatar

    How to turn a top down approach into a naive approach... nice.

  • Custom User Avatar

    In F#, the actual and expected are reversed in test cases. It's a bit confusing when debugging

  • Custom User Avatar

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

  • Custom User Avatar

    That's not very constructive. What don't you like about it?

    For example, I think your solution is pretty clean, but I don't consider the single-line initialization a good practice.

  • Custom User Avatar

    Yeah that's what I was affraid of. Too bad...

  • Custom User Avatar

    Why is the C++ translation using a static class method?

    C++ has global top level functions, so this Arge class really isn't necessary.

    This looks like a bad translation from Java or C#.

  • Custom User Avatar

    Using the mathematical properties of arithmetico-geometric sequences, we can express the problem with a nice equation that we just need to solve.

    This cuts down the computational complexity magnitude to that of log().

    The code is clean, although the rate is useless if percent is 0, and you could have factored aug/(1-rate) into its own variable.

    I like that solution!

  • Custom User Avatar

    Nice recursive approach, although, as with the equivalent iterative approach, it doesn't perform very well.

  • Custom User Avatar

    +1 for the asserts, even though they aren't really necessary.

  • Custom User Avatar

    p0 shouldn't change, it's the starting population.

  • Custom User Avatar

    But I'm not a big fan of the single-line initialization

  • Custom User Avatar
  • Loading more items...