Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
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 onlyO(n)
.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:
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:
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.
How to turn a top down approach into a naive approach... nice.
In F#, the actual and expected are reversed in test cases. It's a bit confusing when debugging
This comment is hidden because it contains spoiler information about the solution
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.
Yeah that's what I was affraid of. Too bad...
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#.
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 ifpercent
is0
, and you could have factoredaug/(1-rate)
into its own variable.I like that solution!
Nice recursive approach, although, as with the equivalent iterative approach, it doesn't perform very well.
+1 for the asserts, even though they aren't really necessary.
p0
shouldn't change, it's the starting population.But I'm not a big fan of the single-line initialization
I like the
for
loopLoading more items...