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.
Having some spaces would be nice for sure. (But if there's a variant with spaces, it's grouped with this solution.)
It's rather the opposite: equally or even more readable, but not better in terms of performance.
Not repeating the same thing. It always returning a value and the value is always derived from another value.
True. But I wouldn't call it a clever (with a negative connotation) one-liner, it's a normal one-liner.
Arbitrary nested - no, but chained like
else if
s look good.True. This is probably worse than anything else about this solution.
(
d
isn't the best name either, but that's form the initial solution.)For people learning to code, they should know that this is NOT best practice.
When working with other people on a large code base, clever one liners are not the answer. That is the reason that there are "clever" and "best practices" buttons.
Nested ternary operators on one line are not easy to read. If I tried to check in a nested ternary operator, a code reviewer would reject my code.
Likewise, it is always best practices to use the same numbers that are presented in the logic. If the company policy reads "7 or more days" the code should show >= 7, not >6.
This will help people make changes later in the event that the policy changes. There is a tendency on this website to never use >= or <= and just subtract 1 from integers in order to save a character.
This is called "code golf" and it is fun and clever, but not best practice.
Here is a style guide for c#:
https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/inside-a-program/coding-conventions
It is equivalent to the ifelse statement, and it exists in many languages.
It's the first choice for lazy people (like me) ;-)
Although, i like your solution.
But i have a question. Is it good practice to right this type of code?
I mean this is not so readable and understandable as compare to basic if else, but it will be efficient i guess.
My main question is where we use these type of logics where we can use if else? What is the benefit? How they help in industry ?
Expected: "S O S"
But was: "SO S"
Expected: "E E"
But was: "EE"
I've got 3 test cases wrong, (the second one twice) and I don't know why.
And I removed with the Trim() method (C#) the white spaces before and after the input.
What's the problem?
Oh! Thanks for quick reply. Working now :)
Check that.
Got 'undefinedEundefined', expected 'E'
Got 'undefined E Eundefined', expected 'E E'
Can anyone help me out, What decodes to undefined in morse code? This is only happening in more complex tests i have passed all the above tests.
First time submitting an issue, hope I'm not going about it the wrong way.
Final fixed test recipe is:
{ oil: '3 tbsp', flour: '2 cup', sugar: '0.5', milk: '1 cup' }
'Sugar' has no unit. Instructions don't seem to cover missing units.
You can bake a basic cake is using the following ingredients
Corrected:
You can bake a basic cake by using the following ingredients