ZooxRoller Coaster Scoring (OOP)
Parse coaster descriptions of the form `<CoasterType> <MaxSpeed> <BumpsPerSecond> <LiftType>` and output `Overall: <score>` per coaster, where Overall = ScaleFactor × ComfortScore × MaxSpeed with type-specific rules for Wooden / Steel / Suspended (Suspended adds a LiftType bonus). Follow-up: make new coaster types and rule changes pluggable without touching the core loop. Usually preceded by ~15-20 minutes of language / OOP trivia.
Problem
Score player-built roller coasters for a game leaderboard. Input is a list of description strings, one per coaster:
<CoasterType> <MaxSpeed> <BumpsPerSecond> <LiftType>MaxSpeed and BumpsPerSecond are numbers; LiftType is one of "Cable", "Chain", "Launched". Only three coaster types are needed now, but the design must scale to 10-20 types and process many coasters efficiently.
OverallScore = ScaleFactor × Comfort × MaxSpeedScaleFactor is a per-type constant. Unless a type says otherwise, the default comfort rule applies:
Comfort = min(1.0, 1.0 / BumpsPerSecond, 1.0 / MaxSpeed)| CoasterType | ScaleFactor | Comfort |
|---|---|---|
Wooden | 1.0 | default rule |
Steel | 2.0 | min(1.0, 1.0 / BumpsPerSecond, 5.0 / MaxSpeed) |
Suspended | 0.5 | default rule, then +0.5 if LiftType == "Cable", with the final comfort capped at 1.0 |
- Output: a line per coaster,
Overall: <score>, rounded to one decimal place. - New coaster types or rule changes must be addable without modifying the core processing logic.
Examples
Input descriptions (as given in the prompt):
"Wooden 4 1.0 Chain", "Steel 20 2.0 Cable", "Suspended 2 1.5 Cable", "Suspended 2 1.5 Chain"Output: Overall: 1.0, Overall: 10.0, Overall: 1.0, Overall: 0.5
- Third coaster by hand: comfort = min(1.0, 1/1.5, 1/2) + 0.5 = 1.0, overall = 0.5 × 1.0 × 2 = 1.0
Variants
- The prompt text changes slightly between sittings, but the structure (per-type ScaleFactor + comfort rule, one formatted line per coaster) stays the same.
- Minority variant: another recalled rule table — read the given formulas carefully and clarify before coding:
Wooden: ScaleFactor 1.0, comfortmin(1.0, 1.0 / BumpsPerSecond)Steel: ScaleFactor 2.0, comfortmin(1.0, 5.0 / MaxSpeed)Suspended: ScaleFactor 0.5, comfortmin(1.0, 1.0 / BumpsPerSecond)plus a lift bonus:+0.5forCable,+0.1forLaunched, otherwise+0- Example inputs seen with this table:
"Wooden 4 2 Chain"→Overall: 2.0,"Steel 20 0 Cable"→Overall: 10.0,"Suspended 2 0.5 Cable". NoteBumpsPerSecond = 0for Steel is only safe because Steel's rule never divides by it.
Hints
Pitfalls
- The statement is long and the coding block is about 45 minutes; there is almost no time to debug. Skip small talk and get to the code quickly.
- CoderPad does not auto-serialize objects when printing (unlike CodeSignal / LeetCode), so print-debugging object state is slow. Keep data in plain fields that are easy to print.
- One candidate failed on how
ScaleFactorwas inherited across subclasses and never got output — decide up front where per-type constants live (class attribute vs constructor argument) and keep that consistent. - Do not copy the default
min(...)into every subclass; reuse it viasuper(). - A rule that divides by
BumpsPerSecondfails when it is0; decide a policy. - It is easy to lose track of which variable is which mid-interview (comfort vs overall, scale factor vs bonus). Name them exactly as the spec does.
- In the onsite variant of this round, the same problem follows ~20 minutes of Python trivia, so the coding time is similarly tight.
- The problem also appears in the onsite trivia + coding round for Go candidates; even with prior practice, finishing every coaster type is hard. A workable plan: implement one coaster type end to end (parsing, scoring, output) first, then add the rest. Interviewers treat the remaining types as copy-paste and accept leaving them unfinished.
- Interviewers often let you skip input error handling during the round, then ask about it at the end.
- A
switch/caseon the type string works but is what the interviewer will ask you to replace; know how to write a registration-based factory in your language before the round.
Talking Points
- Name the strategy pattern: this is a disguised extensibility question.
- Ask whether the Cable bonus is capped at
1.0— the example implies the cap applies after the bonus. - Keep the main loop generic and the registry in one obvious place; handle an unknown type explicitly.
Follow-ups
Preparation
- Write a full solution once end to end in under 30 minutes: parser, one class per coaster type, a registry keyed by the type string, and the formatting step.
- Hand-check the four example outputs (
1.0,10.0,1.0,0.5) against your implementation. - Add a fourth, made-up coaster type to your solution and confirm the core loop needs no change.
- Write the airline-ticket pricing OOP prompt (asked in the same phone-screen slot) the same way before the screen.
