Chickens and Eggs
Updated
Problem statement
baseBirds chickens lay baseEggs eggs in baseDays days. Every chicken lays at the same steady rate, and the numbers may be fractions, as in the classic puzzle.
Return how many eggs birds chickens lay in days days. The answer may be a fraction too. Answers within 1e-6 of the exact value (relative error for values larger than 1) are accepted.
Function
eggs(baseBirds: double, baseEggs: double, baseDays: double, birds: double, days: double) → doubleExamples
Example 1
baseBirds = 1.5baseEggs = 1.5baseDays = 1.5birds = 9days = 9return = 54.0If 1.5 chickens lay 1.5 eggs in 1.5 days, then 1 chicken lays 1 egg in 1.5 days, so a chicken lays 2/3 of an egg per day. Nine chickens over nine days give 81 * 2/3 = 54 eggs.
Example 2
baseBirds = 1baseEggs = 2baseDays = 1birds = 5days = 7return = 70.0One chicken lays 2 eggs per day, so 5 chickens lay 10 eggs per day, and 70 eggs in 7 days.
Example 3
baseBirds = 3baseEggs = 2baseDays = 4birds = 6days = 10return = 10.0Three chickens over four days give 12 chicken-days and 2 eggs, so one chicken-day gives 1/6 of an egg. Six chickens over ten days give 60 chicken-days, so 10 eggs.
Constraints
0.1 <= baseBirds, baseEggs, baseDays, birds, days <= 1000- Every input has at most two digits after the decimal point.
More Jane Street Phone Screen questions
- Maximum-Scoring Consecutive Tree LevelsPHONE SCREEN · Seen Nov 2026
- Tree Selection and VisibilityPHONE SCREEN · Seen Nov 2026
- Load/Store Arithmetic InterpreterPHONE SCREEN · Seen Oct 2026
- Instrument Stack Language JumpsPHONE SCREEN · Seen Oct 2026
- Run a Stack Language InterpreterPHONE SCREEN · Seen Oct 2026
- Positive-Integer Expression EvaluationPHONE SCREEN · Seen Oct 2026
- Add Two Integers Given as StringsPHONE SCREEN · Seen Sep 2026
- Angle Between Clock HandsPHONE SCREEN · Seen Jul 2026
- Route Length From Two CyclistsPHONE SCREEN · Seen Jul 2026
- Sort TradesPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
Similar questions at other companies
- Sqrt(x)LinkedIn · PHONE SCREENLinkedIn interview questions
- Automation Pipeline, Part 1: Single WorkerPlaid · PHONE SCREENPlaid interview questions
- Subtract Two Large Number StringsStackAdapt · PHONE SCREENStackAdapt interview questions
- Transaction Fee Calculator — Parts 1–2: Basic Fee Calculation and Conditional Fee RulesStripe · PHONE SCREENStripe interview questions
- Circular Primes Below a LimitAmazon · PHONE SCREEN
- Palindrome NumberKotak Mahindra Bank · PHONE SCREENKotak Mahindra Bank interview questions
- Streaming AverageXantium · PHONE SCREEN
- Fair Coin from a Biased CoinAnthropic · PHONE SCREENAnthropic interview questions
- Stack Formula InterpreterTypeSafe AI · PHONE SCREEN
- Employee Count Median, Mean and ModeClay · PHONE SCREEN