7 kyu
Recursive Replication
2,623 of 4,183karthikiyengar
Loading description...
Recursion
Algorithms
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.
i used recursion and for some reason i pass the initial tests but i face an error when submiting about reset is not a property in functions in Python
You removed the
@countcalls
decoratorgood kata! for starters, who only begin to wrap their brains around recursion
in ruby in does not even check for recursion, can solve it with a .times method and would still pass the test
I didn't use loops and still didn't work :)
I guess it is because you defined a recursive function inside the main function, and the main function is not called as many times as it should?
You did not use recursion. Not a kata issue.
Suggestion: In the Python version, put a comment next to
@countcalls
telling users not to delete this line. If they do, they get a mysteriousreplicate.reset
error, because of how the hidden tests have been implemented.python new test framework is required. updated in this fork
Approved
This comment has been hidden.
"design a recursive function"
This kata is broken, none of the listed solutions work. replicate.reset() is the culprit.
same problem here
My python code passes all 5 tests, but I'm getting Exit Code:1
Traceback (most recent call last): File "main.py", line 15, in replicate.reset() AttributeError: 'function' object has no attribute 'reset'
Any ideas why? I'm not calling reset() anywhere in my code?
This comment has been hidden.
You should not declare a global variable and reuse it in your function as the scoping varies which can cause unexpected behaviour like the one you have experienced!
This comment has been hidden.
OP solved it, closing
This comment has been hidden.
If you reset the trainer (which will erase your code), you'll see that there's a a decorator
countcalls
applied to thereplicate
function, and it's there for a reason.This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
OP solved it, closing
This comment has been hidden.
Submitted a Haskell translation
Approved it, added random tests, now trying to figure out what is a loop in Haskell and if, how or when to check for that.
Suggestions are welcome. :P
Ruby :
This comment has been hidden.
Check this :
https://www.codewars.com/kumite/5c213d09878179c4070001a8?sel=5c2146d07b3560345c000018
I think that fixes the recursion counter. The main code is in preloaded.
This is a updated fork of the translation :
https://www.codewars.com/kumite/576c27587fdf46969500018b?sel=5c2148817f74a29a0b000032
Seems to be fine now
The random test should have some bugs, because if I run it at atom, it works perfectly... I cannot see why works with the imput (3,5) and fails (3,4) ... and a lot more... I do not use loops...
works fine in python. You're on JS or ruby?
I am on Python.. :) but how can it be, that with imput (3,5) is working and (3,4) fails...?? I printed it in Atom and looks OK even with negative numbers, with zero etc... just while the basic test tell me what is the expected output and what is mine code's, the random test tell me only that it is not the expected output...
The mistake should be mine if 83% could do this, just I didn't find it as in the terminal or in Atom it looks fine..
OK, sometimes fails 36, sometime 39 of the tests... ???
Errr... 83% is the satisfaction rate => 65 persons did the kata in python. ;)
About your troubles: without seeing your code, I can just make weird guesses. From what you describe, I would check for:
It's sure it's on your side, but where? ;) (note: if you want to paste your code here, do not forget the spoiler flag)
the problem is not at your end, it is obviously something about how they are handling recursion at their end. in fact, take a look at that kumite linked above.
I tried a basic list comp and a list generator (5 Jan 2019), and received the following
AttributeError
:C translation kumited!
You should mention what to do for the or case. The description does not mention or at all.
This comment has been hidden.
Hi there, quick wording comment - the word 'as' in 'called as
replicate
' is confusing. Maybe change it to 'calledreplicate
'?Done, thank you!
Python translation submitted :)
Added random test cases. Will figure out the loop validation part when I get the time.
Thanks for the edit. Did not realize that getting the function code is as simple as toString() :-).
You're welcome :)
donald, I made some changes for the Ruby translation of this kata. How can I have these new changes take affect?
This comment has been hidden.
Thank you for your feedback. This is my first Kata and I can't quite figure out how to test for loops. Could you link me to some resources? Will be adding the random tests soon.
This comment has been hidden.
Thank you. Will try this out soon.
Random tests have been added some time ago