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 don't think using regex on a kata called "Regex validate [...]" is missing the point. This regex is also
O(n)
with respect to the input length, notO(1)
.All of these solutions use REGEX. I mean.. it works, and is definitely the best practice because of O(1) complexity but it's also kind of missing the point imo.
Would that not include 5? I thought it was inclusive if you did it that way.
Thanks. Though I haven't updated this kata I feel I feel should mention that I created it before const and let were a part of JS. :)
your code is clear and readable, but one thing, avoid using Var.
Thank you.
This is a damn Readable code. Awesome..
besides not returning directly the expression i believe this can be categorized as best practices.
Regexp in fact is not difficult, at least on this excercise but ist easy to read tho, if you get like those regexp like ^(-.%[a-z+]{4}$-()) and stuff its super complicated, at least for me that i am not a genius considering myself as an average programmer trying who tries to improve lol
In fact for this kata before that i was searching on reg101, regxr, wiki, document, and more to do an exact range of numbers and i cant, then someone teach me about the ^ and $ thats are neede to format explicit a numbers that will be accepted
My opinion
ps. sorry my english
you are missing some white spaces
Apart from the last bit, when you could return directly (isCorrectLength && hasOnlyNumbers), i found that this is the clearest solution. Easy to read, not over-engineered. I think that this community is a bit obsessed about writing super-concise one-liner code: this works and it's super-readable, some developers prefer to write some additional lines of code instead of sacrificing clarity and readability... what's the problem?
I think everyone needs to chill on this one lol
Sure sure, if you mean "any skill level" = "typical Java/C programmer". Yes, regex is incredibly difficult to use in Java and C so nobody uses them there, and hence it's not even taught in most CS curriculum. But this is JS. JS has easy to use regex, and it's a very commonly use part of the language. (The same goes to Python.)
You're submitting a JS solution. JS is not Java.
If you're writing code in a language in the style of a completely different language
, nobody in the world would call your code good. No matter how you believe otherwise.
Conflating "readable and maintainable" to "code monkey tier code" is the real strawman here: again, you're submitting a JS solution, so if you're using pure Java practices, you might as well write a Java solution instead.
Alright - I'd be willing to bet $100 that if you put my solution in front of a developer of any experience level, 99% of the time they would instantly be able to understand what is going on. The same cannot be said for the most popular solution for this kata without having to learn what is essentially another language. Your argument is essentially "to understand this solution, you need to understand this solution", which is even more moot than yours... I'm giggling to myself a little because you're trying to call me out for not knowing a language I have already admitted to not having learnt at the time. You could write the solution in base64 for god's sake, but if you didn't know what base64 was or how to understand/read it, you're not going to have a solution that is understandable by the majority.
tl;dr Nice strawman argument, my solution is understood at any skill level.
...? It's not even a complicated regex (like the one in the top solution). I also argued at that solution, but if regex like that is "hard to grok", "have to untangle the regex in your head" and "causes too much mental load"... then the problem is not about regex anymore, it's about the person reading the code. And the whole point would then become moot: essentially you're asking someone who can't read English to comprehend English.
To be honest, when I made this solution, I wasn't all that great with Regex, so I opted to go for readability. I'd posit this way is much easier to grok at a glance and causes less mental load than having to untangle a regex in your head if the author didn't choose to leave a comment explaining what its purpose was.
I'll hold my hands up and say your second point is completely valid, though.
Loading more items...