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.
HawksLegal please use spoiler flag next time. Your post was visible in the homepage Discourse.
This comment is hidden because it contains spoiler information about the solution
We have to give him that... His solution is unique there :D
Using count? It happens to loop for every element in set, through whole list. In case of multiples dictionary or counter should be used, and there is no other optimal way around, just to iterate over list once.
Another thing is, looking for square is generally longer then apply power if I am not mistaken, so this 'miserable' time difference might be covered by that.
By looking at memory complexity, and complexity in general, this solution isn't best practice at all, clever, maybe.
Yes and no. Even faster solution is with sets for general cases. dict is must have when you have duplicates. You can check my solution for example, maybe something may be improved, but for very large arrays (10^5+) it's a lot faster then this solution :)
Cool, however, not valid anymore :)
...
The top solution IS O(n)...
It seems like only O(n) solution there :|
This solution doesn't meet timelimit anymore.
https://imgur.com/1BskAXk
Image you can use.
Not an issue. A pyramid is not a triangle.
tetrahedron: triangle-based pyramid (it's already in the description)
No
Tests are invalid, generally I guess math solution is poorly implemented or description is lacking.
Example from description:
Layer 1 = X ;
Layer 2 = X | XX ;
Layer 3 = X | XX | XXX ;
Which obviously suggest 3 elements should return 2 - even example says that, but test is hardcoded for 3 elements there is just 1 completed layer, same story goes for 10 elements and 3 layers instead of 4.
EDIT: Okay, solved, but in my opinion, description just lacking in terms of visualizing 3d shape of tetrahedron, otherwise it's faulty/true example, depends how someone would read that, not anyone have to be native english and know what tetrahedron is, I believe that's the reason why visual example should be showed correctly.
EDIT2: Please give me 30 minutes I'll draw you 3d shape myself, and paste link in comment.
This solution was written in Python 2. It does not work because Py2 is deprecated. It needs certain adaptation to Py3 to work with the test cases again.
Loading more items...