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.
expected [ { name: 'red', id: '1' }, { name: 'yellow', id: '2' }, { name: 'black', id: '3' }, { name: 'white', id: '4' } ] to equal
'[{name : 'red', id : '1'}, {name : 'yellow', id : '2'}, {name : 'black', id : '3'}, {name : 'white', id : '4'}]'
Can any one please help me
i tried to find fking mistake about 20 mins in my own same code. I wrote
Javascript
instead ofJavaScript
....Approved
You forgot to add quotes around names and id, not a kata issue!
python new test framework is required. updated in this fork
Look at my faster solution without explicit sort. )))
The expected test results should probably be more like:
"[{'name': '1', 'id': '1'}, {'name': '2', 'id': '2'}, {'name': '3', 'id': '3'}, {'name': '4', 'id': '4'}]"
Regex to the rescue. Most times brings you clean, simple and readable solutions like this to table. Well done!
The overall time complexity of this solution is O(N!⋅NlogN).
Brute force should've been stated in the description of the code, but it does encourage people to write more efficent code.
I initally decided to generate all of the permutations and then give back the next biggest one but tests stopped me from doing that.
Not the most efficent one but probably the cleanest.
Although some comments would've helped
This comment is hidden because it contains spoiler information about the solution
What language do you try?
One difference I notice is missing outer quotes in the actual (i.e. returned by you) value, and present in the epected value. After reading the description I notice that it mentions "objects" everywhere, but actually the answer it expects is a formatted string, so I think your answer has to be a string, and not an array of objects.
expected [ { name: 'red', id: '1' }, { name: 'yellow', id: '2' }, { name: 'black', id: '3' }, { name: 'white', id: '4' } ] to equal '[{name : 'red', id : '1'}, {name : 'yellow', id : '2'}, {name : 'black', id : '3'}, {name : 'white', id : '4'}]'
Can somebody explain what am I doing wrong?
aww , i wanted to do like this but i used forEach
Loading more items...