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.
You may be right, but I like to avoid boilerplate whenever possible. In my opinion it enhances readability to use situational syntactic sugar like this: because it can only be used in certain circumstances, its use highlights that you are in those circumstances.
Perfectly servicable and efficient. Wouldn't best practices encourage adding a
return
line? Obviously not necessary for such simple code.Two ways to calculate avg. expense: 1. sum up all the expenses then take average; 2. take average over differce of balances from start to the end.
It seems only the second way works, but why the first one not? due to precision issue?? With R, it matters when rounding. Should this be mentioned somewhere in the description?
I had the same problem like yours...no clue
What is the rule for rounding here? I tried many rounding methods. I have no idea why 45.525 is expected to 45.53, while 45.105 is expected to 45.10???
I used %.2f with sprintf in R. I am going mad with the rule ........
Thanks :)
ifelse is a vector operator, so you should probably use:
break_chocolate <- function (n, m) {
ifelse(min(m,n)==0, 0, m*n-1)
}
and the function will return for every pair of elements from each vector!
Then forget about my question. Thank you all the same :). Mine is just a suggestion to make things harder, since that might be related to the parse/deparse of expression in the input.
I am sorry but I don't see very well your problem. When in R the input is 0.67 it is 0.67; it's not the result of an operation with large decimals. If you want you can
toString
(it).I mean, 0.67 as input might be either a result rounded from others with large decimals or just 0.67 itself. When it is written as "0.67", then it can only interpreted as 0.67, as parsed input for different languages.
I see there is a package that can take care of making a decimal into the fractional manner. For practice purpose, I guess it might be better not to use additional packages to pass the task (making task more complex a bit :P)
I don't understand what you mean and what your problem is. Note: in R there are packages which use rational...
Thanks for fast reply!
One more thing, I guess there might be a concern of precision of decimal as input for different languages, and hence a string input (e.g., "3/4" or "0.67", instead of 3/4 or 0.67) can refer to exact the one as unique. How do you think? :)
Sorry, I will add something in the description for R.
In R the input is a rational or a decimal, the output is a string.
Examples:
dotest(3/4, "1/2,1/4")
ordotest(12/4, "3")
ordotest(0.67, "1/2,1/6,1/300")
.Thanks for your post.
PS: I modified the description. Is it clearer for you?
Which format of output should be with R language? It seems, for example, the string "1/2,1/4" as output does not work.
Also, it is mentioned the input is a string, but the test example gives it as numeric, which is confusing