e-commerce: Algorithm for calculating discounts

Assuming that: You can compute all available discounts based on your basket Each product can only have a single discount applied to it Each discount can only be used once Then the problem becomes one that is called an assignment problem and can be optimally solved in O(n^3) using the Hungarian algorithm. You will need … Read more

How to detect significant change / trend in a time series data? [closed]

As has been pointed out already, you’re not looking for the derivative. You’re really looking for a “significant change” detection algorithm for a time series. You’ll certainly want a smoothing filter (and the moving average filter is fine — see Bjorn’s answer for this part). But in addition to the smoothing filter, you will also … Read more

What are probabilistic data structures?

There are probably a lot of different (and good) answers, but in my humble opinion, the common characteristics of probabilistic data structures is that they provide you with approximate, not precise answer. How many items are here? About 1523425 with probability of 99% Update: Quick search produced link to decent article on the issue: Probabilistic … Read more

Can any finite bit string be found in pi within a reasonable amount of time? [closed]

Expanding on my comments. There’s a very important concept here that’s called information entropy. Out of full disclosure, I’m the current world record holder of the digits of Pi at 10 trillion digits (10^13). I have approximately 10,000 copies of everyone’s social security number. However that doesn’t mean I can just hack into everyone’s accounts … Read more

Why is builtin sorted() slower for a list containing descending numbers if each number appears twice consecutively?

As alluded to in the comments by btilly and Amadan, this is due to how the Timsort sorting algorithm works. Detailed description of the algorithm is here. Timsort speeds up operation on partially sorted arrays by identifying runs of sorted elements. A run is either “ascending”, which means non-decreasing: a0 <= a1 <= a2 <= … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)