Problem
Leaderboard
🎁 June Giveaway
This June, you have the opportunity to hone your skills and win the Macbook Air, Sony WH-1000XM4 headphones, $50 gift card and much more.
🎮 How to Play
Complete Educative’s daily coding challenge all month.
Choose your preferred programming language before you start, you can switch it anytime, even mid-problem.
Be mindful of your attempts, you only get a limited number, so make each one count.
Keep your streak alive, the longer it runs, the more raffle entry tickets you rack up.
Earn tickets and increase your chances of winning the draw.
🎟️ How to earn Tickets
ActionTickets Earned
Complete Daily Challenge
+1
10-Day Streak
+10
20-Day Streak
+20
30-Day Streak
+30
LinkedIn post with #30DaysofCode Everyday (and tag Educative)
+2 per post
Most-Liked Post Overall
+20
Top of Leaderboard
+50
Leaderboard: 2nd place
+30
Leaderboard: 3rd place
+20

Problem: Soup Servings

Statement

You begin with two types of soup, A and B, each containing n milliliters. During each turn, exactly one of the following four operations is selected uniformly at random (each with probability 0.250.25), independent of all prior turns:

  • Serve 100100 mL of soup A and 00 mL of soup B.

  • Serve 7575 mL of soup A and 2525 mL of soup B.

  • Serve 5050 mL of soup A and 5050 mL of soup B.

  • Serve 2525 mL of soup A and 7575 mL of soup B.

The serving from both soups happens simultaneously in each turn. If an operation requires serving more than the remaining amount of a particular soup, simply serve whatever is left of that soup. The process terminates immediately after any turn in which at least one soup becomes empty.

Compute and return the probability that soup A becomes empty before soup B, plus half the probability that both soups become empty at the same time. Answers within 10510^{-5} of the true value will be accepted.

Note: There is no operation that serves 00 mL of soup A and 100100 mL of soup B.

Constraints:

  • 00 \leq n 109\leq 10^9

Problem
Leaderboard
🎁 June Giveaway
This June, you have the opportunity to hone your skills and win the Macbook Air, Sony WH-1000XM4 headphones, $50 gift card and much more.
🎮 How to Play
Complete Educative’s daily coding challenge all month.
Choose your preferred programming language before you start, you can switch it anytime, even mid-problem.
Be mindful of your attempts, you only get a limited number, so make each one count.
Keep your streak alive, the longer it runs, the more raffle entry tickets you rack up.
Earn tickets and increase your chances of winning the draw.
🎟️ How to earn Tickets
ActionTickets Earned
Complete Daily Challenge
+1
10-Day Streak
+10
20-Day Streak
+20
30-Day Streak
+30
LinkedIn post with #30DaysofCode Everyday (and tag Educative)
+2 per post
Most-Liked Post Overall
+20
Top of Leaderboard
+50
Leaderboard: 2nd place
+30
Leaderboard: 3rd place
+20

Problem: Soup Servings

Statement

You begin with two types of soup, A and B, each containing n milliliters. During each turn, exactly one of the following four operations is selected uniformly at random (each with probability 0.250.25), independent of all prior turns:

  • Serve 100100 mL of soup A and 00 mL of soup B.

  • Serve 7575 mL of soup A and 2525 mL of soup B.

  • Serve 5050 mL of soup A and 5050 mL of soup B.

  • Serve 2525 mL of soup A and 7575 mL of soup B.

The serving from both soups happens simultaneously in each turn. If an operation requires serving more than the remaining amount of a particular soup, simply serve whatever is left of that soup. The process terminates immediately after any turn in which at least one soup becomes empty.

Compute and return the probability that soup A becomes empty before soup B, plus half the probability that both soups become empty at the same time. Answers within 10510^{-5} of the true value will be accepted.

Note: There is no operation that serves 00 mL of soup A and 100100 mL of soup B.

Constraints:

  • 00 \leq n 109\leq 10^9