7 kyu
Sum of a nested list
1,510 of 3,197kingcobra
Loading description...
Recursion
Lists
Algorithms
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.
Haskell translation
Hopefully this translation stays within the spirit of the original kata, as the elements must be homogenous in a standard Haskell list.
python: Mutating the input list breaks random tests.
fixed by OP's fork
python new test framework is required. updated in this fork
Approved
Python :
Fixed by OP's fork
Ruby 3.0 should be enabled, see this to learn how to do it
Enabled in this fork
My Code is Working well on every test but i am getting a STDERR in the end test. Can you explain me why is this happening.
See if this helps: https://docs.codewars.com/training/troubleshooting#test-attempt
Great!!! Now i'am getting a bunch of errors :(
This comment has been hidden.
this is not clear: Testing with: [[86, 69, 99, [11], 76], 27, 27, 5, 14] [[86, 69, 99, [11], 76], 27, 27, 5, 14] 414 should equal 0 why should it equal 0? i pass all the tests besides random tests,its really not clear this is litterly the description: Implement a function to calculate the sum of the numerical values in a nested list. For example :
sum_nested([1, [2, [3, [4]]]]) -> 10
Normally when only random tests fail, it means you mutate the input affecting the expected output.
with respect, i was asked to return sum,i did,its so weird when u do what u have to do and then some mutate term pops up.. so,i think in real life i solved the problem :)
no. Actually, in real life, you got fired... x)
;)
This comment has been hidden.
ok,it is a very important theme in codewars and its stated a lot but since im not a programmer, and i could not really understand what it means,could anyone please please shortly explain and or demonstrate what it means?? thanks !
Crystal translation available :)
Sorry I didn't see it earlier. Approved!
Could be a bug! Please check your test assertion in "11 should equal 10", because my IDE works correct !
hi...
CCL: closing.
Feel free to open a new issue if you can demonstrate that there is effectively a flaw in the tests and that it's not a problem with your code, or ask for a "Question".
cheers
1.Python
I have tested manually all Sample Tests, where I have corect assert with my IDE! Please take in mind that I have an error in the "Run Sample Tests", not in Attempt btn! And most interesting, that I passed first test, and on the second I have "11 should equal 10", but my script return 10!!
So, okay, I can send to you my solution and you will see whats goin on !
python sample tests are correct. You must have modified them accidentaly. Just reset the trainer (button at the bottom right).
This Kata sucks because it is not solvalble due to wrong test implementation!
Random tests Log Testing with: [77, 46, 65, 2, 23] 213 should equal 0
WTF? I calculated the correct number but you expect 0 ?
@author/translator: if you do not want issues raised again and again, you should take care of that.
Language is PYTHON There was no mentioning of dont touch input.
it's almost never mentionned. But it's NEVER good practice for the programmer to mutate the input (has you just discovered ;) ).
It is 2017 and pure functions are basically a must; I would also refrain from commenting on how a kata might "suck" just because I was the only one getting issues out of tens of other successful solutions.
OK sorry on being a bit rude but that was after wasting some precious time on this. Okay I am still learning Python but I thought if you want to rely on the fact that your collection is not touched (which the random test implementation seems to do) you should better use immutable collections. But okay...
Sadly that is not always the case (you don't always work with immutables) and in any case thinking in terms of pure functions is to be preferred and encouraged :)
Note that the argument should be
lst
or something like that, notL
Approved (shorter and shorter...)
Like lightning.
I changed the argument, thanks for the tip!
How did this get approvable? Hasn't this been done a thousand times by now ?!?
I made a few searches before writing the kata. There is none that exactly matches this one. Of course, it is basic, but that's the point of a 7 or 8 kyu kata. The most similar one I could find is this : https://www.codewars.com/kata/sum-of-nested-numbers, which requires a bit more work to solve.
To be fair, the only difference is that that kata requires you to transform the numbers in the arrays with
Math.pow
as well, it's not a big one.Yeah, but you also have to keep track of the nesting somehow, which is irrelevant in this one.
Well, for me it was harder than some of 5||6 kyu kata.
Difficulty is always relative! ;)