Problem
Ask
Submissions

Problem: Poor Pigs

Medium
30 min
Explore how to determine the minimum number of pigs required to identify a poisonous bucket within a set timeframe. Understand the timing constraints and testing rounds to efficiently solve this logic and math-based coding problem.

Statement

You have buckets buckets of liquid, exactly one of which is poisonous. Your goal is to identify the poisonous bucket by feeding liquid to some number of pigs and observing whether they survive or die. You have a total of minutesToTest minutes to determine which bucket contains the poison.

The experiment proceeds in rounds according to the following rules:

  • Select any number of live pigs to feed during this round.

  • For each selected pig, choose any subset of buckets to feed it. The pig drinks from all chosen buckets simultaneously and instantaneously. Any pig can drink from any number of buckets, and any bucket can be consumed by any number of pigs.

  • Wait exactly minutesToDie minutes. No pigs may be fed during this waiting period.

  • After the waiting period, any pig that consumed the poisonous bucket will die; all other pigs remain alive.

  • You may repeat this process as many times as the remaining time allows.

Given buckets, minutesToDie, and minutesToTest, return the minimum number of pigs required to guarantee identification of the poisonous bucket within the allotted time.

Constraints:

  • 11 \leq buckets 1000\leq 1000

  • 11 \leq minutesToDie \leq minutesToTest 100\leq 100

Problem
Ask
Submissions

Problem: Poor Pigs

Medium
30 min
Explore how to determine the minimum number of pigs required to identify a poisonous bucket within a set timeframe. Understand the timing constraints and testing rounds to efficiently solve this logic and math-based coding problem.

Statement

You have buckets buckets of liquid, exactly one of which is poisonous. Your goal is to identify the poisonous bucket by feeding liquid to some number of pigs and observing whether they survive or die. You have a total of minutesToTest minutes to determine which bucket contains the poison.

The experiment proceeds in rounds according to the following rules:

  • Select any number of live pigs to feed during this round.

  • For each selected pig, choose any subset of buckets to feed it. The pig drinks from all chosen buckets simultaneously and instantaneously. Any pig can drink from any number of buckets, and any bucket can be consumed by any number of pigs.

  • Wait exactly minutesToDie minutes. No pigs may be fed during this waiting period.

  • After the waiting period, any pig that consumed the poisonous bucket will die; all other pigs remain alive.

  • You may repeat this process as many times as the remaining time allows.

Given buckets, minutesToDie, and minutesToTest, return the minimum number of pigs required to guarantee identification of the poisonous bucket within the allotted time.

Constraints:

  • 11 \leq buckets 1000\leq 1000

  • 11 \leq minutesToDie \leq minutesToTest 100\leq 100