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.
A reasonable optimizing compiler will produce the same machine code regardless of whether the variable is defined before the if-check or after it. Initializing local variables has no effects visible to callers so the compiler may freely reorder the code as it sees fit.
The reason is just style and clarity. First of all, it's common to add preconditions to the start of a function. If there are no items, we already know the answer and we can return right away. Second, it's generally a good idea to keep the scope of variables as small as possible.
Of course, in such a short function it doesn't really matter, but if a long function defines variable in the very beginning and uses it a lot later, can you be sure that there are no uses between? You have to carefully read through the whole function to check if there are other references.
This comment is hidden because it contains spoiler information about the solution
What abt thease brackets inside the parentheses, could you explain why he puts parenteses if he's reffering to the array, and why putting - between the two extremes of the array and most importantly, why the hell it works inside the two double quotaions :) m just curious to know more about thease notation :)
Fixed.
Maybe, but speed isn't usually particularly important with this kind of string replacement. Your solution appears to be about 9x faster, which might matter in some cases, but definitely doesn't for this kata-- or most real-world applications-- but 8 lines vs 1 for a simple string character replacement function does. 2.6 million operations/s is plenty.
I did finish it using 0.082 for R. I would argue though that the description does not say it is, but rather a calculation where one of the factors is 0.082.
Those are units, and the only one left is
atm
when you return the pressure.R
is a constant.Excactly where does R come from ?
The description says "R=0.082dm3⋅atm⋅K−1⋅mol−1", but atm isn't anywhere to be found. Unless you count the return value.
Being a level kyu8 kata it couldn't hurt to give up the number intended used for mol and atm.
That's its numeric value with the units used in the formula, yes.
So, is R 0.082?
both approved
Parameter names are fixed in this C fork and this NASM fork.
You can change gM to mass, mM to molarMass.
This comment is hidden because it contains spoiler information about the solution
gM
are given mass,mM
are molar mass, and they are given in the same order as in the "Input" paragraph of the description.But you are right, they are confusing, I will add some description.
Loading more items...