[Community Puzzle] Metric Units

Coding Games and Programming Challenges to Code Better

Send your feedback or ask for help here!

Created by @Grarzyna,validated by @FredericLocquet,@nguyen.lam and @Westicles.
If you have any issues, feel free to ping them.

:wave: Hi to all :grinning:, and thanks to @Grarzyna for this puzzle !
I’ve pass all the tests, but :open_mouth:surprisingly it fails to the 9th Validator :thinking:
:pray: please, can someone tell me the Units of the 2 parts in “Validator 9”, please ?
maybe i’m wrong in rounding one of the values to the new unit …
Thanks by advance for your help, please :wink: !


Test Case

13.0908mm + 13um


1 Like

:+1:Thanks a lot @Yatech for your help :slight_smile: : your precious information worked for me …
→ it was effectively a round problem :handshake: with my previous code !
Thanks again :+1: :+1: :clap: :handshake:.
and thanks too to the Author @Grarzyna for this contribution to the community.
+Maybe “Merci” to the validators @FredericLocquet,@nguyen.lam and @Westicles :fist_right: :fist_left:.
bye to all. Have :sun_with_face: sun, :slight_smile: fun and :dark_sunglasses: Condingames :rofl: !

had so much fun solving this puzzle, thanks Grarzyna! :smiley:

What’s Validator Case #6?

It’s very very very similar to Test #6.

What are the rules around decimal precision in this exercise? Sometimes it’s 2 places, another time it’s 4 places, and most of the time it’s no decimal places. Understanding the decimal precision requirement would go along ways.

The requirement is to show all the significant decimal places, i.e. no trailing zeros after the decimal point.

Hmm, well here’s what I’m seeing:
#6 debug: value: 315.320007 to arbitrary decimal place: 315.32
#7 debug: value: 10.009801 to arbitrary decimal place: 10.0098
#9 debug: value: 16051.800781 to arbitrary decimal place: 16051.8
To me, the arbitrariness is that I have to allow the decimal to the first set of numbers it runs across and then cut off after having another trailing zero. Why is there an onus of having decimal point precision, instead of simply having fun making it an int - or setting a requirement of specific number of decimal places (e.g. 2). How do you have access to see the validator and know how it is similar to problem #6? Another question, are there issues with different architectures and the precision of decimal places in large numbers (and really small numbers too) - isn’t that why there’s a cutoff for a specific number of decimal spots? Just curious because there doesn’t seem to be an answer that allows me to progress, only keeping me running in circles when everything looks okay.

Apparently the issue is between using a float and a double for precision in this case, that using a float will give an approximate answer; but using a double will yield the correct answer. As you can see from the values above that a float value is quite wrong in some cases for the calculations. The same results from above using a double are as follows:
#6 debug: value: 315.320000 to arbitrary decimal place: 315.32
#7 debug: value: 10.009800 to arbitrary decimal place: 10.0098
#9 debug: value: 16051.800000 to arbitrary decimal place: 16051.8

Yes, using a float or a double may cause differences in the calculations.

I guess the statement can be more clear about the issue to avoid frustrations. Currently it does contain a constraint stating the input value is “with precision <= 0.00001”.

I have access to the validator as my level in CG is high enough (I think one has to reach level 29 to have that access right).

In respect of your other questions, I cannot answer them on behalf of the author.

For anyone having problem with rounding (JS, Typescript):

16.0408 * 1000 => 16040.800000000001
Number(16.0408+‘e3’) => 16040.8