Pythonic way to check if a list is sorted or not
Is there a pythonic way to check if a list is already sorted in ASC or DESC
Is there a pythonic way to check if a list is already sorted in ASC or DESC
I’m having trouble wrapping my head around a algorithm I’m try to implement. I have two lists and want to take particular combinations from the two lists.
I tried to write code to solve the standard Integer Partition problem (Wikipedia). The code I wrote was a mess. I need an elegant solution to solve the problem, because I want to improve my coding style. This is not a homework question. Answers: Thank you for visiting the Q&A section on Magenaut. Please note … Read more
Input: "tableapplechairtablecupboard..." many words
I’d like to compare 2 strings and keep the matched, splitting off where the comparison fails.
Can someone explain to me an efficient way of finding all the factors of a number in Python (2.7)?
What is the cost of len() function for Python built-ins? (list/tuple/string/dictionary)
What algorithm is the built in sort() method in Python using? Is it possible to have a look at the code for that method?
Recently I needed to do weighted random selection of elements from a list, both with and without replacement. While there are well known and good algorithms for unweighted selection, and some for weighted selection without replacement (such as modifications of the resevoir algorithm), I couldn’t find any good algorithms for weighted selection with replacement. I also wanted to avoid the resevoir method, as I was selecting a significant fraction of the list, which is small enough to hold in memory.
I have a scenario where a user wants to apply several filters to a Pandas DataFrame or Series object. Essentially, I want to efficiently chain a bunch of filtering (comparison operations) together that are specified at run-time by the user.