Based on lano1'idea:

https://discuss.leetcode.com/topic/66856/major-flaw-in-current-algorithm-fixed

Here is python code:

```
def poorPigs(self, buckets, minutesToDie, minutesToTest):
"""
:type buckets: int
:type minutesToDie: int
:type minutesToTest: int
:rtype: int
"""
# corner case
if buckets == 1:
return 0
if minutesToTest // minutesToDie <= 1:
return buckets - 1
# general case: just get the n in n^(test_times + 1) = buckets
return int(math.ceil(math.log(buckets, (minutesToTest // minutesToDie) + 1)))
```