Discovered today that there’s no inbuilt nCr function in any of the popular Python modules. Tried itertools, numpy, sciPy This can’t be true? What am I missing? Seems odd to have write it out using math.factorial or use a helper function. Maybe I’m abnormally lazy.
-
-
Replying to @_awbery_
yeah, that's how it is. itertools.combinations gives you subsequences. if you want the nCr number you have to implement it yourself. good responses on this SO question, gives a more efficient way than using factorialhttps://stackoverflow.com/questions/4941753/is-there-a-math-ncr-function-in-python …
1 reply 0 retweets 1 like -
Replying to @danlistensto
Glad to have it confirmed, thanks. Yes, I was looking for the nCr number function.
1 reply 0 retweets 0 likes -
Replying to @_awbery_
it is surprising that it's not in the standard library. kinda goes against the "batteries included" design philosophy of Python to exclude it like this, even though its simple to implement it yourself.
1 reply 0 retweets 0 likes
Yeah, that’s why I asked publicly. I wondered if there were some less used mathy library I hadn’t come across yet. Easy enough to add it to my own modules, but just seemed odd.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.