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.
Based on the author's solution, there seems to be an implicit assumption that whatever the size of the outer array, is also the size of each of the inner arrays. If this is the case, it needs to be explictized (and will probably invalidate some answers). All the current tests hardcode a length of 3, and the random tests of the Python translation hardcode the inner array size as 3. The description should be cleaned up to sort this out, as it makes adapting this Kata awkward into languages that support tuples or compile-time sized arrays because each person who adapts this Kata seems to make a different set of assumptions.
Oh neat I assumed
std::multiplies<void>
only had one template parameter like the regular version does. CoolThis comment is hidden because it contains spoiler information about the solution
Yup, the updates do not change any part of the functionality at all. The changes just update the
assert equal
syntax in the fixed tests. The part of the random tests with the customized assertion messages was not touched whatsoever since I was already using the "newer" syntax because the older syntax doesn't allow you to customize messagesn
should bestd::size_t
, notint
. This change would remove the need for the odd cast in theif
. Variables throughout your code that are supposed to represent an index or a size should bestd::size_t
private
section of theDescribe
struct, and keep the existing code in apublic
section. Here is an example#include
:<vector>
,<cstddef>
,<random>
(more on that below)ExtraMessage
. Many examples on how you can do so in this example suite<random>
instead. Link to the relevant docsconst std::vector<int>&
instead of by valuereturn {};
to the body of the solution setupTODO
comment on top of each snippet. It's bound to confuse some solversSince this Kata has been/will be adapted to languages where going out of bounds throws or invokes undefined behavior, the description should explicitly note that
n
can be larger than the array's size. It's 8kyu, so I think we should give the solvers some grace and have them pre-emptively handle edge cases instead of flying into exceptions or crashes.
approved by someone
Fork published
Fork of
eurydice5717
's translation that resolves this issue caused by overflow. Each call to generate a random value now constructs its own int distribution, removing the arithmetic and guaranteeing that the numbers are in range.Approved
LGTM! Approved. One minor quirk is that operations like
(disb(gen)%(extra/2))+1
return a lower bound that is one-less than the JS version (ex:1
here instead of2
). It infinitesimally increases the likelihood of integer divisions, but that seems harmless to me (since thefinite division
section in JS also generates integer divisions every now and then). If another reviewer finds this a deal breaker, it can be forkedVery faithful translation, but I would like to point out one issue and offer 3 suggestions:
referenceSolution
being a free public function means it is visible to the solver, who can invoke your function to pass the tests (after a simple forward declaration). Consider moving it into theprivate
section of theDescribe
structtest
function to this so the solvers receive error feedback:<cmath>
,<utility>
)stringstream
andsubstr
-ing out the zeroes can be replaced with a clearer one-liner The library handles the zeroes for you, and returns a result identical to what you've hand-rolledEverything else LGTM
(
#include <fmt/core.h>
assumed for #2 and #4)C# Translation
Gripes with the description that I feel should be addressed:
Loading more items...