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.
I think the kata description was updated. That should explain all the solutions that check for space instead of non-alphabetical characters.
I solved it without them, but I really wish I didn't...
Fixed.
Unfortunately the philosophy of the people running the show at codewars is hostile to that sentiment. They are not focused on providing educational or useful katas, and do not attempt to filter based on that criteria at all. The best you can do is skip the bad katas that are focused on massaging the ego of the kata's author when you recognize them (saying this random coding unrelated geometry trivia is "elementary" for example), or just unlock solutions and move on if you don't see anything useful. In all honesty, take a look at some kata authors and you'll notice a pattern... you might want to skip katas from them entirely.
This gets around the tests by checking for spaces in the city name, but the description does say to exclude any non-alphabetical characters as well which this would not pass were that tested.
Good use of short-circuit evaluation, helped me clean my code up.
The brackets
[]
are a way of accessing an object's property called bracket notation.The more common way like
ops.propertyName
is called dot notation.I use bracket notation here because it allows you to use variables, and dot notation does not.
ops[operation]
returns the property value matchingoperation
if it exists, and undefined otherwise. The property value for + - * / are all function references.ops[operation]()
returns that function reference from the[]
and then knows to actually execute the function because of the()
. It's just like calling a method with dot notation. If you accidentally typeObject.method
instead ofObject.method()
, you get a function reference instead of executing the function.In my solutions it's not an IIFE because the function was defined inside of the object, then invoked later rather than immediately.
Can you pls explain what does
ops[operation]()
mean in this code, what is that bracket for? It can't be an IIFE since you're accessing it with an object..This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Correct me if I'm wrong, but basically you're asking to provide every piece needed to solve the kata in the description. Where's the fun in that? (for a math kata)
Researching is a fundamental skill everyone should develop, and those who are unsatisfied below simply have no research abilities, or expect to come up with a formula while staring at a blank screen.
I don't like these kind of formula katas 1 bit, but providing such formulas in description would defeat the entire purpose of a kata of this type.
You don't seem to understand, you want to reduce this puzzle kata to this:
And there are a lot of other katas that do exactly that, we don't need more of those. You can not do some katas if you don't like them, nobody forces you to complete them all. Puzzles are just that, a game, not a Fundamental kata where instructions should be complete.
Looking up for things you don't know, being coding or something else, is a skill everybody should practice.
87% of 1,961
That's the satisfaction rating of people who solved the kata and voted from
13,091 of 25,664 (more than 50%)
Warriors that solved it. Popularity is relative.
You can't solve a puzzle without the pieces. Providing relevant information to solve a kata is not spoonfeeding people, it's giving them the necessary pieces to solve the puzzle. By gatekeeping the puzzle pieces behind arbitrary knowledge/trivia checks, you aren't challenging people to be creative and thoughtful... you're just making them waste their time googling irrelevant trivia that could have been included in the description. You either know the trivia or you don't.
If you read the other discussions on this kata (and similar ones), you'll see multiple upvoted comments expressing frustration with both the content and description. Geometry trivia masquerading as coding challenges is not popular , especially when the relevant trivia is not explained within the description.
Most authors understand this intuitively and provide relevant information on their own. For those that don't, what's the harm in improving the description based on feedback?
Don't give hints please. I marked your comment as a spoiler. If it is not in the description there is a reason. Users are supposed to be able to search trivial stuff like this if they don't know it.
It's a puzzle, you don't need to spoonfeed it.
Loading more items...