+ 1
Max is planning to take part in a Diwali contest at a Diwali party that will begin at 8 PM and will run until midnight ( 12 AM
Max is planning to take part in a Diwali contest at a Diwali party that will begin at 8 PM and will run until midnight ( 12 AM ) i.e.,for 4 hours .He also needs to travel to the party venue within this time which takes him P minutes. The contest comprises of N problems that are arranged in order of difficulty, with problem 1 being the simplest and problem N being the most difficult.Max is aware that he will require 5*i minutes to solve the i th problem. Your task is help max find and return an integer value, representing the number of problems Max can solve and reach the party venue within the given time frame of 4 hours
10 Respuestas
+ 1
The future of coding...
prompting for answer.
+ 1
Do I miss something?
He also needs to travel to the party venue within this time which takes him P minutes.
...Max can solve and reach the party venue within the given time frame of 4 hours
If Max takes 0 minute to arrive to the venue, he starts at 8:00 PM.
If he takes 10 minutes to arrive, he starts at 8:10PM.
If he takes 236 minutes or more to arrive?
+ 1
Wong Hei Ming
I fed the question to Sololearn's AI. I got this reply:
Given:
- The party starts at 8 PM and ends at midnight (12 AM), which is a total of 4 hours.
- Max needs to travel to the party venue, which takes him P minutes.
- It takes Max 5*i minutes to solve the i-th problem.
Total time to solve problems = 4 hours (240 minutes) - P minutes
Next, we need to calculate how many problems Max can solve within the remaining time frame:
The time required to solve X problems = 5*1 + 5*2 + ... + 5*X = 5*(1+2+...+X) = 5*X*(X+1)/2
So, we solve the following inequality:
5*X*(X+1)/2 <= total time to solve problems
Now, solve for X:
5*X*(X+1)/2 <= 240 - P
5*X*(X+1) <= 480 - 2*P
X*(X+1) <= (480 - 2*P)/5
The valid solutions for X are the integer values that satisfy the inequality above.
Finally, return the maximum integer value of X that satisfies the inequality as the number of problems Max can solve and still reach the party venue within the given time frame.
+ 1
you'd still have to solve quadratic equations... and the answer will be range of values depending on p.
Idk if it's correct, but I got 9 if p is minimally small .
+ 1
Bob_Li
Yeah, P minutes has a big impact, and I solved it with Excel.
I think Max can cook an instance noodle and finish it before step into the venue, yet still solve 9 problems if he does arrive early.
+ 1
Not sure is it a good idea or not, since you already posted your code, I post my too with a different solution.
I think our solutions works, unless OP is concerning the "return" part, as we didn't defined any function.
https://sololearn.com/compiler-playground/c1I5m1GjZ7im/?ref=app
0
I need answer for this question
0
ok, here's a no quadratic formula solution
https://sololearn.com/compiler-playground/cYdL5iCBVOI8/?ref=app
0
solution using cmath for quadratic formula proposed by AI.
https://sololearn.com/compiler-playground/cZX8HN3CbGV8/?ref=app
0
Wong Hei Ming
Your solution is even simpler and more elegant. 😎 minimising p while maximising x.
AI actually proposed a more complicated solution that prevented me from seeing a simpler solution.
I guess it's also one of the dangers of AI. Now I worry more about the future where everything is handed to AI... It could complicate everything that we would end up totally relying on it.