A clear explanation
Suppose there are 10 buckest, 10 minutes to test and the pig dies after 3 minutes. then we can test at most 3 rounds. For each bucket, a big can drink it during
Suppose there are 10 buckest, 10 minutes to test and the pig dies after 3 minutes. then we can test at most 3 rounds. For each bucket, a big can drink it during round 1 or round 2 or round 3 or not drink at all ( 4 possibilities ).  Convert each bucket to a number of base 4. \n\n0 - 00\n1 - 01\n2 - 02\n3 - 03\n4 -10\n5 - 11\n6 - 12\n7 - 13\n8 - 20\n9 - 21\n10 - 22\n \nWe need at most 2 digits to represent 10 buckets with base 4. Each digit represents a pig. The number indicates at which round should the pig drink water in this bucket. \n\nTake bucket 6 as an example, 12 means, pig 1 should drink water in bucket 6 during round 1, pig 2 should drink water in bucket 6 during round 2. if pig 1 dies in round 1 and pig 2 dies in round 2, then bucket 6 is poisonous.\n\nSimilarly, for bucket 8, pig 1 should drink its water during round 2 and pig 2 don\'t need to drink water in this bucket. If pig 1 dies in round 2 and pig 2 is not dead then bucket 8 is poisonous. \n\nThe problem is converted to how many digits are required to represent a number.\n \n```\npublic int poorPigs(int buckets, int minutesToDie, int minutesToTest) {\n\n        int base = minutesToTest / minutesToDie + 1; //total possibilites\n        return Math.ceil(Math.log(buckets) / Math.log(base)); // number of digits to represent n buckets with base  \n        \n    }\n\n
[]