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.
In this kata there is no function name for bash, you must just write the instruction to
echo
the expected result, assuming that the input is$1
(I agree this is a bad design, but one can find the same on some other katas...). I always had the impression shell set up was a bit awkward on Codewars. At least a single comment could be included in initial code giving basic indications. I agree this should be considered an issue, but actually I believe many shell katas would desserve to be revisited in the same sense.The kata's description is shared amongst all languages and in most of them you need to write a function. If you think that bash instructions should be different, then create an issue.
In shell, this kata only has a single test case, it needs more.
OK. Solved it in quick and dirty way. As tests are ... there are no tests for Bash. The problem was with kata's wording.
The author writes: "Your task is to write a function that takes a string ..."
A function!!! WTF! What he/she really wants is just a command with args, not a function!
To solve this kata in a proper manner just write a command, not a function. That's it folks!
In Bash it should be
func_name(){echo "${*}" | and here command that devowels input string}.
I know it, and it works in scripts. Been writing for years.
But how on Earth is it to work here? Please, help with a hint.
I do know the command itself. It's not sed params, them I know.
I am interested in syntax. Tried it with an old format (function func_name {etc.}). Didn't work either.
Example for plural endings in Russian (hour - hours, minute - minutes):
1 час -
2 часа -
5 часов -
1 минута -
2 минуты -
5 минут
Well, the docs are very clear when it comes to explaining the
raise
keyword. This is the standard, most acceptable way of reporting that something went wrong in the code. What would you suggest instead?I'm not trying to sound condescending (and I hope I'm not being toxic here!), but I don't understand how you could possibly use
try
here.Thanks. I do know about documentation. Please, take trouble and read it (your link). From the first page you've got try:/except: examples of raising ValueError. What I suggested, might improve this kata and Codewars in general. If there would be less trouble with single instances (katas), the better resourse it would be. Yours (1 kyu rating) is not for being toxic, right? :-)
Not a lot better but, what about this?
That shows this error:
I noticed this but I have no good idea how to prevent this. The crappy message comes from Chai :( I will try to figure something out, maybe craft my own assertion.
There's the official documentation you know...
OK. Not everyone (1 dan) yet here. Searching for 'raising ValueError' and code skills previously learned lead people to try:/except: solutions. None of which, obviously, works.
And these katas are for codders who are not expert-super-duper pros. They are for novices. That is why a helpful hint in description of the kata, or a hint in test evaluation would be much appreciated by them. To that, I admit, that I confused "raising an error" with "handling an error". Now will remember the difference. Thanks.
rejected by someone, and the author closed their account
but... what are the "another methods of raising ValueError"? You confused "raising an error" with "handling an error" -
try:/except:
is used to handle errors raised by someone, somewhere, and not to raise errors. The description asks users to raise an error and not to handle an error, and this should be enough of an explanation thattry/except
in your solution is not needed. How would I have to change the tests or description to help with such confusion?Was really confused by "raise ValueError" part. Tried to do it as usual in try: except: blocks. The code worked fine locally, but not here in Codewars. This kata tests should either include tests for another methods of raising ValueError or change description. For codders to come: do not use try/except here. You'll find the right way quicker to get through this kata.