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.
C++ version. Contrary to the description, negative arguments are fed to the function.
The expected results for negative fractions look strange: Incorrect result for fractionToPeriodic(-1689246217, 36291): Expected: equal to "-46547.(-2-4-90-9-7-5-7-2-400-...)"
Horrible solution. Perfect example of how to kill performance by making code shorter. Solutions here are expected to have O(n) and compete only in number of passes through the list, but this one manages to get to O(n^2).
That kata now already has a Java translation. Also this kata requires to merge the frequency count and prime factors in string format, so technically not an exact duplicate.
Also, duplicates of Prime Factorization katas has been mentioned here and will be handled sooner or later.
There is an issue for original kata and you better not inherit it. There really should be explicit tests with repeating minimum in the array. For example [3, 4, 3, 5] should produce 6, not 7. I guess, single fixed test is ok.
.
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.C++ version. Contrary to the description, negative arguments are fed to the function.
The expected results for negative fractions look strange:
Incorrect result for fractionToPeriodic(-1689246217, 36291): Expected: equal to "-46547.(-2-4-90-9-7-5-7-2-400-...)"
Approved
C++ translation waiting for comments or ... approval :-)
This is by far the most performant and elegant solution.
Horrible solution. Perfect example of how to kill performance by making code shorter. Solutions here are expected to have
O(n)
and compete only in number of passes through the list, but this one manages to get toO(n^2)
.I don't think modular arithmetics is basic math, but I guess that is a matter of perceptioin.
That kata now already has a Java translation. Also this kata requires to merge the frequency count and prime factors in string format, so technically not an exact duplicate.
Also, duplicates of Prime Factorization katas has been mentioned here and will be handled sooner or later.
Corrected!
Thanks for the feedback!
There is an issue for original kata and you better not inherit it. There really should be explicit tests with repeating minimum in the array. For example
[3, 4, 3, 5]
should produce6
, not7
. I guess, single fixed test is ok.The solution is incorrect. It fails if the minimum element repeats anywhere in the array.
I dont know why Swift translator added it here, but other translators have not. Its been reported before too.
Loading more items...