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.
LOL, translating it from a python solution doesplain why it isn't a very "R" way of doing things!
This comment is hidden because it contains spoiler information about the solution
This is supposed to be coding practice though. It's like if the task was to sort a vector and you used R's built-in
sort()
function. Yeah... that works, but then what's the point? This is supposed to be a 6 kyu exercise, meaning it should take more than using a built-in function to accomplish.Fixed broken R kata with a fork.
https://www.codewars.com/kumite/59b8ba985227dd140200000b?sel=5f6de9a0b0d883002923f25c
This makes the problem trivial and is therefore not a good solution.
Fixed Kata with a Fork: https://www.codewars.com/kumite/59b8ba985227dd140200000b?sel=5f6de9a0b0d883002923f25c
Yep, still an issue half a year later.
R Kata still broken 5 months later.
Fixed R translation added which eliminates the triviality of the exercise in R.
https://www.codewars.com/kumite/5cc0d38e449d880019738cb8?sel=5f62ec06ab84150019b4e598
Any chance I can get someone to help me clean up the collective mess of R katas?
Corrected R translation added.
https://www.codewars.com/kumite/59f66c4025d5756d340000fb?sel=5f629d84e4729a002391aa93
Original reference solution appears to have been copy/pasted from some source as it includes code for using dice with other than 6 sides.
Original test cases test for a sum uniformly sampled from 10 - 40 and a number of dice uniformly from 2-7. This has the effect of approximately 43% of all test cases being degenerate, that is the target sum is larger than the highest possible total from the number of dice. New random test cases first select a random number of dice, then simulate that number of rolls and use that number as the target, ensuring there are no degenerate random cases. Degenerate cases are included in the sample tests. An assumption is made that degenerate cases are essentially the same so there is no reason for the random tests to include them.
Orgininal reference solution attempts a closed form solution for caluclating the probabilities. This solution, however, generates results outside the stipulated margin of error in as few as 36 dice.
New code performs tests with up to 400 dice.
This comment is hidden because it contains spoiler information about the solution
Nice recursive solution, but will hang for any modestly large number of dice, e.g.
This should NOT be considered a best practice.
It will most likely crash any R instance if the number of dice exceeds 8 or 9. At only 9 dice this solution will attempt to construct a
data.frame
object with 6^9 rows and 9 columns (90699264 elements) then try to reduce that to a vector with a length greater than 10 million, in the process doing 10 million 9 element sums. Then doing 10 million comparisons, then finally summing 10 million logical values.This should NOT be considered a best practice.
It will most likely crash any R instance if the number of dice exceeds 8 or 9. At only 9 dice this solution will attempt to construct a
data.frame
object with 6^9 rows and 9 columns (90699264 elements) then try to reduce that to a vector with a length greater than 10 million, in the process doing 10 million 9 element sums. Then doing 10 million comparisons, then finally summing 10 million logical values.This comment is hidden because it contains spoiler information about the solution
Loading more items...