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.
I will repeat what I said in the post just below.
First I notice that 69 people passed the R tests.
I will try to explain but my explanation is maybe not the best.
Idealy when working with floats one begins by multiplying and not by dividing (you begin with the division..) to avoid multiplying the error caused by computers in divisions.
My explanation:-)
1.92 - 1.47 = 0.44999999999999996... (given by computers)
(1.92 - 1.47) * 3600 = 1619.9999999999998...
((1.92 - 1.47) * 3600) / 20 = 80.9999999999999858 (calculated with R, for example use
formatC(max(v), digits = 16, format = "f")
)Then you take the int or the floor (because police don't want to penalize you:-) you get 80.
In some other languages I used a tolerance of 1 but (sorry for that) not in R.
You don't have "to use floor(round(v, 6))". Simply made the operations in good order (mmultiplication before division) and at the end take the floor; if you do like that you will find 80. I think (but I can be wrong): it is a good example of calculating in a correct way with floats). Cheers!
I'm currently trying to solve this kata in R, but I think there is an error with the expected value in test 3. My code (and also a simple calculator) give me 81 as solution, but 80 is expected.
Test Input:
s: 12
x: c(0, 0.11, 0.22, 0.33, 0.44, 0.65, 1.08, 1.26, 1.68, 1.89, 2.1, 2.31, 2.52, 3.25)
Maximum can be found in position 8 which is [1,91 - 1,47]
Doing some math, I get: ((1,92−1,47)/20)⋅3600 = 81
and not 80.
So currently, I cannot solve the kata in R unless I cheat.
Update: Seeing it in other comments, I cannot resolve this issue by using "floor". To complicate it even more, I have to use floor(round(v, 6)) to pass all the other tests. Apparantly, R math deviates quite significantly from the expectation in several cases.
Fixed the test case in python.
Yes. Not pretty - but I still wanted those credits ;)
how did you bypass this ? hardcoded ?
-edit-
Sorry, double post.
-edit-
Nevermind, solved.
Also had to bypass the test case. Still not fixed.
apparently, that was to make sure to handle the {input == 0} case separately...
It still doesn't seem to be fixed yet. As many reported, in the hiragana test case,
\ufffd
Was presented as part of the solution after encryption, but it is NOT part of the alphabet. And it was NOT part of the original text. Because it does not originate from the text (and could only come from a shift within the given alphabet) it should never be part of that solution.
Edit: I bypassed the last test by obvious means. But I guess it would be better to solve the test case :).