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.
"Out of interest do you know if this kind of data structure has been used anywhere?"
I second that! Searched around the web for clues but found none so far.
Also wonder what's the optimal data structure for implementing it - some kind of DAG? I'd very much like to see a purely functional solution.
That's true but the description never promises more than "Define a function ... that takes one integer argument...". Don't mind me, I'm just a math nerd :)
This comment is hidden because it contains spoiler information about the solution
Not best Ruby practices, since it's using "for" and unnecessary "return", otherwise - nice.
I'm not sure what you mean with your question :) While this:
means you drop every third mango from the calculation (because it's free by definition), your snippet -
((quantity / 3 ) * 2) * 2
- is not mathematically equivalent to the former (hint: integer division is not exactly like float division).I like your solution best (dunno if it's most idiomatic, being Elixir newbie myself), it's most readable and goes the farthest (along with
g964
's) before it hits some Erlang integer minimum (namely,-1.797e+308
) when calculating the partial sum (according to my naive test set):Interestingly enough, the solution using
Stream
gives up some~500
years earlier :) (probably due to the suboptimal interest rate calculation)Although it doesn't work for negative integers :)
All tests pass green but I can't submit the solution - I can click the "Submit" button multiple times and it just runs the tests over and over again, not letting me proceed. :(
This comment is hidden because it contains spoiler information about the solution