7 kyu
Combine objects
8,361 of 9,436matthewglover
Loading description...
Arrays
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.
Brilliant kata, although it felt more like a 6kyu.
Python new test framework
Approved
Nice kata.
Guys, need help. My code passes all tests in VS Code, but the CodeWars compiler throws an error on 4 out of 6 tests. What should I do?
OP solved it, closing
Very interesting and smart kata to solve, thanks to author!
I can't understand Incredible flight of the authors fantasy. In the example section he shows that function must work with 2 arguments, looking in base tests we need to discover that function can have three arguments... OK, I wrote solution that pass all base tests but when I press "Attempt" button I recived 10 passed and 11 wrong. I think the problem occours because of incorrect or incomplete initial information.
How I can guess what data contains failed tests?
Print the arguments, and:
It does say two or more there. You don't need to discover anything if you read that.
This comment has been hidden.
I think that everything is in order with the tests, look for the problem in the solution. You need, as described in the instructions for the kata, "+" the values of all input dictionaries into the new dictionary. Look at the author's examples and tests.
Ok i guess i found it thanks
Not a kata issue.
Well, I'll say this is far from 7 kyu. 8 kyu was like peanuts, and 7 others went well, and this one, well, I think the level of 6-5( Difficult, and it was not interesting at all(
This has to be the hardest 7kyus I've done... Spent over an hour reviewing Object methods to solve this!
This comment has been hidden.
This comment has been hidden.
I don't know why my results are wrong. My code should work. NVM. I didn't see the last line that you can't change the original input.
Please help. I dont understand: python
How arguments come in function?
It's stated very clearly. It should take any amount of arguments.
Thank you! What a pity that sometimes I am very inattentive:(
JS: Node v12 should be used along with its appropiate assertion tools (Mocha + Chai). Refer to this and this
Node v18 enabled in this fork
Ruby 3.0 should be enabled.
Enabled in this fork
Python 3 should be enabled.
This kata is a great way to familiarize yourself with the basics of objects (among other things), and it also prompted me to learn about the importance of .hasOwnProperty.
This comment has been hidden.
user has solved the kata. Question resolved
This comment has been hidden.
Hi - I think you're right. I agree that order of object properties shouldn't matter. The problem is with Test.assertSimilar, which I had assumed did a deep equality check, but in fact just converts the object to a string representation and then compares that. I've had to write a small helper function
testDeepEqual
to do actual deep equality checking (using lodashisEqual
). So issue should be fixed.Confirm: problem solved. Thanks!
i am baffling to understand this behaviour
*A { j: 54, p: 85, c: 100, n: 44, z: 85, l: 36, q: 55, k: 70, x: 57, y: 5, w: 38, d: 84, r: 26, u: 89, s: 77, v: 18 } *B { r: 62, c: 55, m: 87, j: 20, b: 54, v: 87, d: 0, u: 13, a: 85, k: 64, n: 45, y: 27, h: 67, p: 17 } *C { w: 57, p: 29, z: 25, k: 66, h: 56, a: 94, g: 43, o: 6 } Test Passed: Value == {"j":74,"p":131,"c":155,"n":89,"z":110,"l":36,"q":55,"k":200,"x":57,"y":32,"w":95,"d":84,"r":88,"u":102,"s":77,"v":105,"m":87,"b":54,"a":179,"h":123,"g":43,"o":6}
*A { w: 93 } *B { m: 37, z: 68, q: 46, w: 77, c: 56, j: 59, x: 1, n: 56, f: 48, a: 39 } *C { i: 3, u: 90, a: 75, j: 25 } Expected: {"w":256,"m":95,"z":68,"q":46,"c":56,"j":84,"x":1,"n":56,"f":142,"a":114,"i":3,"u":90,"k":14,"d":33,"r":34,"y":9}, instead got: {"w":170,"m":37,"z":68,"q":46,"c":56,"j":84,"x":1,"n":56,"f":48,"a":114,"i":3,"u":90}
how may i suppose to get w:256, any light towards this would be a great help.
The function can take more than 3 objects as arguments. Are you using all arguments or just the first three?
Yeap, was using just the first 3, my bad. thanks for your help.
This comment has been hidden.
Two options in Javascript:
Option 1 works on all browsers, so is more universal. Option 2 syntax is much nicer. Hope this helps. Good luck!
he cant read it because it's marked as a spoiler so this isnt much help to him
Sorry @veronicacannon - didn't realise that flagging it stopped people seeing my comments (thought it just flagged it up as potentially spoiler so gave you the option). Have unflagged it now.
Thanks @matt c and @matthewglover I appreciate your hint.
I should have specified that I'm trying to train in Ruby. Isn't everyone using Ruby? :)
And just an fyi, I'm a her, not a him.
Ah ok - I'm more of a frontend web person so my Ruby is a bit unpolished. But I think what you're looking for is the splat operator, which gathers all args into an array (like the spread operator in JavaScript). Haven't actually tried my own kata in Ruby so not sure I'm qualified to help, but hope that's of some use!
Yes! That's a great idea, thank you @matthewglover
Javascript initial template has nothing to do with the kata...
Thanks - I've updated it
I had a blast translating them and solving with one-liners: thanks matthew :)
Translated into both Python and Ruby; description might need edit accordingly, but let me suggest you to first approve the translation and eventually adding examples for those languages :)
To me it was the best kata of the week so far (no offence meant to the others, just personal taste!), but I would force at least one edge test case expecting
{}
as a result; got it in only one random tests (they should be many more, if you ask me).ASAIC, I will work on translating this good stuff :)
Isn't it very similar to this one: http://www.codewars.com/kata/add-a-property-to-an-object Only "add" instead of "throwing errors"...;-)
Well, this one is much more complex, asking you to add a bunch of attributes taking X objects, so I don't say many overlapping :)
Edit to the above: having 1 empty object in the fixed cases would be good.
So it's no problem - it only was my "déjà vu";-)! Perhaps others can solve the easier one too:-)...
This comment has been hidden.
This comment has been hidden.