5 kyu
multiply(value, times)
206wthit56
Loading description...
Strings
Fundamentals
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
Please add Python to this question! I don't really remember how to do Javascript!
This isn't a kata issue. A suggestion maybe.
Ok then-
No sample tests.
I don't understand why my code fail after passing number, string and function tests by execution time out: running the examples test cases run fine, and I cannot imagine what could take as much time to hang the attempt between testing multiply function and remainded tests (I suppose that only object, null-like values and error cases/invalid values are missing at this point) ?
After 3 month without answer to my question, I have inspected again this kata and finally found why my code timed out and quickly fix it: 'multiplied' functions should be able to be called more than once (obviously, but I previously cannot figure it: if this could help anybody ^^)... so timeout was caused by infinite recursion due to my counter missing reset to 'times' argument ;P
Ah. Sorry, mate. Been a while since I was really active on CW, so the notification email must've fallen through the cracks. Glad you found the bug, though. ;D
This should be tested.
Done. 👍
This comment has been hidden.
I figured it out! XD
The function is tested more than once. The first run through passed, but the second run through failed. This is because you permanently changed the number of times it's meant to run to 0, during the first run. So on the second run, it runs the function 0 times.
Typos in the code block section in examples:
It should be:
I think I've fixed this now. Thanks for your help!
You misspelled multiply as "mutliply" several times in the description, as well as "stirng" as string in the examples. Please do a copy edit.
Thanks for bringing it to my attention. I think I've fixed them all now ;P
The decription is very unclear, specifically in regards to how to handle functions and objects. The description states in regards to functions:
'Each time the original function is called, the context and arguments should be preserved.'
There is no notion of their being arguments anywhere else in the description. What arguments? This is very unclear.
I've added an example for each value type, which should make things clearer.
When a function is "multiplied", it should create a new function. That function could be called with a context, and arguments. This context and any arguments should be given directly to the original function that was multiplied. The example should make this clearer, but do let me know if not.
wthit56 improved the description. So I think after 2 years this issue could be closed.
Cheers ^^
The description could be more informative and clear now it might bring ambiguities that will add further frustration when trying to complete this kata. Lack of proper function execution step explanation is also frustrating, it might be a good idea to provide a clear and concise description what you should implement each step by step to complete this Kata. Now the description feels like out of the place. You get introduced with the conditionals of the assignment which should be seperated from the main requirements of this kata, in my opinion. Function/ Object declaration explanation should be at the top and perhaps rephrased to suit less advanced/beginner programmers.
There is no required "steps" you have to implement. You can do things in any order you like, using any techniques you wish. The value types are listed, along with how they should be "multiplied". The
function
explanation uses the correct terms; this isn't meant to teach the coder what those terms mean and so on. With any deeper an explanation, I'd just be dictating the code. I'm sory, but I am not sure how I could make it any easier to understand, to be honest."If value is not a number, times can be any integer >= 0. If these conditions are not met, an error should be thrown."
You'll need a test for value != number, times != integer throwing an error.
Good idea; must've forgotten that edge-case. I've added a test in the "Errors" section for this. Thanks for your help!
"Anything else: should be returned as-is."
There is no test for this.
Fair dos. I've added tests for this, and also added a further edge case that Infinity "times" should throw an error.
Thanks for your feedback.
Bah, silly null, having a type of object.
Yeah... ;P
I did nothing for the function type, but still it is passing the tests.
Is it normal ?
No--faulty tests. I've fixed them now, though. Thanks for bringing this to my attention!
I'm confused what we're supposed to be doing with
function
values. I returned a function that can call the functiontimes
times, but now it's complaining about arguments?I figured it out, but you should probably clarify that part a bit better.
Fair point. I've added a note about context and arguments preservation. Does that make more sense now?
Yup, that should do it.
Thanks for your help, mate.