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.
It is stated that
1--1
is valid and that an unary minus is not separated by a whitespace before parentheses. Your example follow these rules.Hi everyone, I use haskell language.
In random tests, I get a random input string
"((((94.0))-54.98))-89.28-(88.66)+-59.25+75.61+4.88/(44.42)/(79.75)*-60.81*3.72/(19.72*10.46)-58.1/(7.55)*23.37+32.0/(97.63)-(79.92*(1.71-16.82))/(--(28.95)/((55.88/(67.58))))/(69.66)+95.05*(37.3*(5.1*44.66*39.81)-17.23)*80.85+(48.43/(86.06))*(-88.39)/((32.31-31.49*32.76))"
to calc, I get a substring
--(28.95)
, Is that right? I am not found this rule in the description.tht s nothing. i just fixed it . But my code did pass all the tests anyway
Tests are not ideal but they are correct. It is hard to create randomized tests which catch all possible bugs. Your solution does not work for some simple test cases like this one:
The expected result is
7.263867809057526
but your solution returns-915.278670000000034
.A simplified version of this test case:
Expected:
8
, your solution:799.087999999999965
.Dude u gotta improve the tests, 'cuz i tell ya, they’re broken! Sometimes my code passed sometimes it didn’t.also there were two cases in the fixed tests where my code gave me the right answer when tested in VSCODE, but your tests gave me a totally different answer. Note that I used the same code! To solve this issue, i had to manually handle these two cases! You gotta revise your tests guys, they’re broken!
Yes, it is always true for Java and for any sane programming language. You still need to be careful with more complicated expressions and if you use a low-level programming language like C with specific compiler flags (e.g.,
--ffast-math
): It is possible that you get different results on different machines even if they are IEEE-754 compliant.Historically, the original version of Java was not strict with floating-point arithmetic and it was possible to get different results on different machines (but always the same results on the same machine). That's why Java had the modifier
strictfp
to make sure that floating-point results are reproducible (it was removed in Java 17).Sorry for a bit dumb question.
Does this mean that if I do something like
on one machine it's always going to be true?
Chill :c
You guys shouldnt be allowed to make any KATA. My experience was horrible. tht s the first time i had an experiance tht bad on codewars. The creators of this KATA are so terrible! Anyway i solved it but i am not satisfied!
Please do not open new issues unless you can confirm that your solution is correct and tests are wrong. Floating-point arithmetic is not random. You always get the same result if you follow all computation steps in the specified order. Did you see my reply to your previous issue?
calculate (((7.20/ -3.84- -2.23-9.14/7.037.42+ -8.85+8.12-8.73+7.39/(7.15+6.73+8.91/8.36+8.16/9.75)))+((7.46)-7.07-7.26/7.33/6.91+5.45-9.308.22/9.55-9.99*(6.71/ -6.70-5.05/ -7.75+9.839.47+8.04+6.90)/7.40+7.828.84+8.14+9.95+(6.35))/(((8.58+5.40+ -7.258.20/8.568.03+8.02-9.09/ -1.137.93/6.06+ -9.21+9.93+6.01+9.896.38/9.39* -1.17/ -9.58- -8.42/8.42+ -1.36/6.33/ -6.85+5.42+9.32+7.82+9.41+7.75+8.03/ -7.52)))) should be -20.5390898263107289, got -20.5390898263107253 can someone solve this ,everyone knows floating point has limitations u guys cant ask for this level of precision in your tests when it comes to float ! Been working on this problem for almost 12 hours , 3 hours per day and now cant ask me to come up something tht s impossible
Both Python and JavaScript return
-20.490663944447256
for this expression. So there are no issues with tests.Make sure that you evaluate all operations with the same precedence from left to right and use library functions to convert decimal numbers to floating-point numbers.
Your current solution fails the following simple test case:
1-(6-3) == -2
but you solution returns1
."calculate ( -7.42/7.83-5.98* -5.01/9.08* -8.59+8.80) should be -20.490663944447256, got -20.4906639444472596" Why am i getting this is it my code or an issue with the tests?
I am backk! Lts go bby!!!
Huh?
Loading more items...