good point of not using a dictonary!
the other points should't be changed:
don't leave out the slicing of 'names' inside format(), as this results in much slower performance for long name lists.
making that if/else shorter degrades readability and performance
same goes for separating the "like(s) this" part
this would be a good approach:
out = ( 0: 'no one likes this',
1: '{} likes this',
2: '{} and {} like this',
3: '{}, {} and {} like this',
4: '{}, {} and {others} others like this'
)
def likes(names):
return out[min(4, len(names))].format(*names[:3], others=len(names)-2)
You should encourage using a lambda (~arrow function) in ruby by putting one in the initial solution, and by using lambda calls: e.g. odds[[1,2,3]] (instead of odds([1,2,3]))
On the other hand, it doesn't make much sense in python, as there are no arrow functions.
The barrier for entry for beginners is non-existent - for solving kata. ( Well, assuming you can multiply two numbers together. )
Creating kata is a whole other ballgame, and it should be viewed not as a right but as a privilege. The quality of the kata on CodeWars is too important for that. New kata should be held to high standards. ( Existing kata could also be held to higher standards than they are now. )
I actually like the idea of not allowing users to vote on kata under their own rank. In this form it won't work, but it's still an interesting idea.
good point of not using a dictonary!
the other points should't be changed:
don't leave out the slicing of 'names' inside format(), as this results in much slower performance for long name lists.
making that if/else shorter degrades readability and performance
same goes for separating the "like(s) this" part
this would be a good approach:
out = ( 0: 'no one likes this',
1: '{} likes this',
2: '{} and {} like this',
3: '{}, {} and {} like this',
4: '{}, {} and {others} others like this'
)
def likes(names):
return out[min(4, len(names))].format(*names[:3], others=len(names)-2)
nice
Note:
{1,}
is the same as+
Cool. I'd just modify the pattern to (\d{1,})(\D*) so you don't need to filter out the last element.
guys, one line solution looks very impressive.
But are you sure that such code is readable (especially for a developer with little experience)? :)
Please refer to the issue by Johan to see if it needs a bit of description update.
Merge conflict :/
Sure, it's similar, but hopefully a bit more difficult. That is, if I manage to ban imports...
IDK about an average solution, but for me it's duplicate of https://www.codewars.com/kata/5d076515e102162ac0dc514e
lol
Your enthusiasm is appreciated, but we already have tons of fibonacci katas in ruby and python
You should encourage using a lambda (~arrow function) in ruby by putting one in the initial solution, and by using lambda calls: e.g.
odds[[1,2,3]]
(instead ofodds([1,2,3])
)On the other hand, it doesn't make much sense in python, as there are no arrow functions.
Wish I knew that before.
Note taken!
The barrier for entry for beginners is non-existent - for solving kata. ( Well, assuming you can multiply two numbers together. )
Creating kata is a whole other ballgame, and it should be viewed not as a right but as a privilege. The quality of the kata on CodeWars is too important for that. New kata should be held to high standards. ( Existing kata could also be held to higher standards than they are now. )
I actually like the idea of not allowing users to vote on kata under their own rank. In this form it won't work, but it's still an interesting idea.
Ruby translation kumited, including a clearer description -- please review and approve (note: author is inactive)
Loading more items...