As in the original translation: "Please don't use public for the reference solution..."
For the recursion test I would test that the method was actually called with arguments n, n-1, ..., 1 via ArgumentCaptors since you can just call factorial(0)n-1 times and then calculate with a for loop or so. Additionally the recursion should not force to stop at n==1 but could also go to n==0 so exactly n times is too restrictive. Also I would recommend to use a bigger value for this test as n==2 can be rolled and this not really representative value to check for recursion.
You can go up to n==20 in the random tests without overflowing long range.
Please do some more random tests, e.g. 10
If you want to put the effort in you could update to JUnit 5 and use org.junit.jupiter.params.ParameterizedTest and org.junit.jupiter.api.RepeatedTest
Rounding intermediate values is ++UnGood. Don't do it. Comparing da * vb to db * va is a perfectly good way to compare intermediate values without introducing floating point representation inaccuracy ( if it introduces overflow, get bigger datatypes ). But distances and speeds should not be modelled as integers anyway.
Not raising as an Issue because this will be retired anyway.
I can see that for Groovy/Kotlin languages, as an example, there are no such Katas, maybe what you say is more applciable to JS
Because nobody translates those katas to Groovy/Kotlin, not because they were "authored for a specific language".
I hope it can serve good for Codewars community
Duplicates and low-effort katas certainly don't add any value to CW. If you don't unpublish this kata, it will be retired due to low satisfaction rating anyway.
Hello.
Could you plese review and approve the Translation for GROOVY - https://www.codewars.com/kumite/65fdbe00825c8314779bd103?sel=65fdbe00825c8314779bd103.
Thank you
n, n-1, ..., 1
via ArgumentCaptors since you can just callfactorial(0)
n-1
times and then calculate with a for loop or so. Additionally the recursion should not force to stop atn==1
but could also go ton==0
so exactlyn
times is too restrictive. Also I would recommend to use a bigger value for this test asn==2
can be rolled and this not really representative value to check for recursion.n==20
in the random tests without overflowinglong
range.org.junit.jupiter.params.ParameterizedTest
andorg.junit.jupiter.api.RepeatedTest
Ehhh... very simple :) Looks good
Hello @user8436785 ,
Forked and added this translation - https://www.codewars.com/kumite/5d0437ab11bd8c002086eeaa?sel=62b6cf6d0ee74b011f9f9458
Though your setup will most likely work,
a more Kotlin-ish solution would be:
I'd also leave out the class for the solution setup and just take the function.
The test can also easily be written in a loop.
Let me know what you think :)
@acraileanu, I changed it so that streams lambdas are used. Please check if it is OK.
Thanks!
I wonder if we could use the lambda operator in the solution to convvey the "arrow"-ness?
.filter(x -> x % 2 == 0)
Hello,
Could you please check and approve the Java Translation (https://www.codewars.com/kumite/62124fda1d5475001661ee49?sel=62124fda1d5475001661ee49) of the kata.
Thanks
Hello All,
I can see that the method names are now OK and tests seem to be fine.
Can this kata be approved?
Thanks
Java translation added. Please review and approve it.
Hello! Kotlin translation added to the Kata. Could you please review it and approve :)
Hello! Kotlin translation added to the Kata.
Rounding intermediate values is ++UnGood. Don't do it. Comparing
da * vb
todb * va
is a perfectly good way to compare intermediate values without introducing floating point representation inaccuracy ( if it introduces overflow, get bigger datatypes ). But distances and speeds should not be modelled as integers anyway.Not raising as an Issue because this will be retired anyway.
Because nobody translates those katas to Groovy/Kotlin, not because they were "authored for a specific language".
Duplicates and low-effort katas certainly don't add any value to CW. If you don't unpublish this kata, it will be retired due to low satisfaction rating anyway.
@ejini战神, @XRFXLP
Added sample and random tests. Please check if now it is OK.
Thank you for the help!
Loading more items...