Python binary
Drink or not drink is binary 0 or 1, so we can encode buckets using binary encoding using pigs.\n\n### Code\npython\ndef poorPigs(self, B, D, T):\n\ttmp = log2(
Drink or not drink is binary ```0``` or ```1```, so we can encode buckets using binary encoding using pigs.\n\n### Code\n```python\ndef poorPigs(self, B, D, T):\n\ttmp = log2(B) # number of pigs for one shot\n\tt = ceil(T/D) # number of tests we can conduct\n\n\tif t == 1:\n\t\treturn ceil(tmp) # one shot is the answer\n\treturn ceil(tmp / log2(t+1)) # re-use pigs until the answer is found (# of tests)\n```\n\n### Intuition\nWe can come up with the solution starting from simple scenarios\n* 1 or 2 buckets --> 1 pig is enough (right, this one\'s trivial)\n* 3 or 4 buckets --> 2 pigs are enough, because the task is similar to identifying buckets using binary values (i.e. ```0``` and ```1```)\n\t* bucket1 : noone drinks it\n\t* bucket2 : pig#1 drinks this bucket\n\t* bucket3 : pig#2 drinks this bucket\n\t* bucket4 : both pigs drink it\ni.e. we can use ```log2(B)``` pigs to identify each bucket by looking at which pigs have died and what they drank i.e. ```1```\n\n### Thinking process\n![image](https://assets.leetcode.com/users/images/b99f1259-11d9-4d9f-bb53-ebcb39b7549a_1659776913.623787.jpeg)
['Python']