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.
C# is for the bigger and bolder.
You missed the point I was trying to make. It doesn't matter how you write it, with an
if
block, or with a ternary, or usingmin
,max
, the performance difference is miniscule between all of these methods. If someone sat you down in front of this solution and told you to optimize it, and you changed themin
,max
variable assignments toif
blocks, then you would have failed the task. Nobody cares that one of these is a few hundred microseconds faster than any of the other ones.Your claim that changing the code to what you've written above will "shave off a third of the execution time" is only true for a small range of (a..b) due to the speed of the rest of the solution. In other words, if you run the original solution at the top of the page with very large inputs (like 0, int.MaxValue / 2) and compare it to one where you've replaced the variable assignments with your ternary expressions, your ternary assignment one no longer shaves off a third of the execution time (It will likely only shave off like .00002% of the execution time, if anything).
Wow I don't even know what to say. I cannot believe that this phony "2 dan" user "Blind For Basics" (heh) could make such elementary errors about the BASICS of programming. I don't see what's so hard about KISS either, everyone knows Gene Simmons hates LINQ.
Is that clearer?
BTW, that's not the usual meaning of KISS so you've basically been calling stupid to everyone you said KISS without your intended meaning, so you know.
Ok, could you please refrain from posting messages that overall do not really make sense or are mostly there to "bitch" at other users? (...who you don't even know)
For example, KISS is the opposite of micro optimizations. Talking about both in the same sentence/§ is just none sense.
Second, the tone used will just attract epidermic reactions on you from any reader (just look at the downvotes on your message).
Third, By reading some of your other messages here or there, I can tell you don't fully understand yet the difference between Big O and actual runtime, how to manipulate those notions and in what context, to stay meaningful, or how to test the actual performances of a solution (...and talk about it: announcing a time without explanations about how it was measured, with what inputs, how many tests, ... is just a waste of... time).
Overall, you're obviously focussing way too much on the wrong things, for now, considering your programming journey.
Some users posted interesting answers to some of your previous messages, but I doubt you saw them because they are flagged as spoilers. You might want to go check for them (you can find them through your profile "discourse" page).
Have a good day & cheers
spoiler flag, please. The comments are visible from the dahsboard.
This comment is hidden because it contains spoiler information about the solution
If you have a billion-character string then calling
ToLower()
on it will create another billion-chararacter string. Most likely, it will be slower to create this second string than callingChar.ToLower()
for each character twice.It will still run it once for every character under the hood.