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.
Passing float instead of integer to a function raises more likely
TypeError
instead ofValueError
.(see for example https://github.com/python/cpython/commit/f066bd94b9225a5a3c4ade5fc3ff81e3c49b7b32)
May be more interesting to switch to
TypeError
instead.The code is nearly identical:
Sir, you are nitpicking here :'-)
Code golf version
Edit: 126 characters
You are not going to spoil that much with an example yielding 2 or 3, especially due to the meeting difficulty being linked to nested brackets.
This comment is hidden because it contains spoiler information about the solution
Recursion limit is 1000 by default in Python.
Given this limit, in worst situation, this solution can generate numbers up to (1000 - 3) // 6 - 1 = 165 bits.
However Python has also an undocumented limit on nested parentheses when trying to
eval
a string which is 200 only.Not all kata are designed for interview.
If you expect all solutions to be prod-ready, you are not on the right website.
Here is a suggestion to learn from this solution: you should ask for explanations politely.
It may bring you more insights than complaining.
This comment is hidden because it contains spoiler information about the solution
Slower but less memory
When writing
x * b'\0'
, if not mistaken,memset
is used to set one unique value to multiples addresses.The given value is directly written at the correct addresses, no intermediate values involved.
This comment is hidden because it contains spoiler information about the solution
There is no need to repost a solution that is that similar to your previous one.
Codewars allows to create forks of your solution by clicking on Fork under your solution ;-)
This comment is hidden because it contains spoiler information about the solution
Some insights about factorization function:
n
.q
reachessqrt(n)
: there is no new factor after this limit.d = 6-d
is used to generate a 2,3-wheel that scans only only one third of all possible factors - factors withq % 6 in (1, -1)
.More exactly it returns the left side if it is false-ish.
It is similar to the following:
It is called short circuit evaluation in Python and it is also available with
or
operator.Loading more items...