Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create PoorPigs Problem 458 #464

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Vatsal2010
Copy link

It was the daily problem on 29th oct

Problem:
There are buckets buckets of liquid, where exactly one of the buckets is poisonous. To figure out which one is poisonous, you feed some number of (poor) pigs the liquid to see whether they will die or not. Unfortunately, you only have minutesToTest minutes to determine which bucket is poisonous.

You can feed the pigs according to these steps:

Choose some live pigs to feed.
For each pig, choose which buckets to feed it. The pig will consume all the chosen buckets simultaneously and will take no time. Each pig can feed from any number of buckets, and each bucket can be fed from by any number of pigs.
Wait for minutesToDie minutes. You may not feed any other pigs during this time.
After minutesToDie minutes have passed, any pigs that have been fed the poisonous bucket will die, and all others will survive.
Repeat this process until you run out of time.
Given buckets, minutesToDie, and minutesToTest, return the minimum number of pigs needed to figure out which bucket is poisonous within the allotted time.

Description

Upon reviewing the problem seems to be related to determining the minimum number of pigs needed to find the poisoned bucket within a certain time frame, considering the constraints on the testing time for each pig. The code employs dynamic programming to solve the problem, using a combination of factorials and a 2D vector to keep track of intermediate results.

My initial thoughts on solving this problem would involve understanding the constraints and requirements thoroughly. This includes analyzing how the testing time for each pig affects the overall strategy, the concept of dynamic programming, and how to leverage it to optimize the solution.

I would also consider the relationship between the number of pigs, the testing time, and the total time available to solve the problem. This understanding is crucial to come up with an efficient algorithm that minimizes the number of pigs required while ensuring the poisoned bucket can be identified within the given time frame.

Additionally, exploring the problem through a few examples to understand its nuances and intricacies would be a crucial step. This approach can help in devising a comprehensive plan for solving the problem effectively and optimizing the code for efficiency and scalability.

It was the daily problem on 29th oct
@welcome
Copy link

welcome bot commented Oct 29, 2023

I can tell this is your first pull request! Thank you I'm so honored. 🎉🎉🎉 I'll take a look at it ASAP!

@Vatsal2010 Vatsal2010 closed this Oct 29, 2023
@Vatsal2010
Copy link
Author

HacktoberFest is Ending!!

@Vatsal2010 Vatsal2010 reopened this Oct 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant