PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates proficiency in string parsing, floating-point arithmetic, conditional logic, and designing extensible rule-based scoring systems.

  • medium
  • Zoox
  • Coding & Algorithms
  • Machine Learning Engineer

Compute Roller Coaster Scores

Company: Zoox

Role: Machine Learning Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

You are given a list of roller coaster descriptions. Each description is a string in the format: `<CoasterType> <MaxSpeed> <BumpsPerSecond> <LiftType>` Examples: - `"Wooden 4 2 Chain"` - `"Steel 20 0 Cable"` - `"Suspended 2 0.5 Cable"` For each coaster, compute an overall score using: `OverallScore = ScaleFactor * ComfortScore * MaxSpeed` The `ScaleFactor` and `ComfortScore` depend on the coaster type: - `Wooden` - `ScaleFactor = 1.0` - `ComfortScore = min(1.0, 1.0 / BumpsPerSecond)` - `Steel` - `ScaleFactor = 2.0` - `ComfortScore = min(1.0, 5.0 / MaxSpeed)` - `Suspended` - `ScaleFactor = 0.5` - `ComfortScore = min(1.0, 1.0 / BumpsPerSecond) + LiftTypeBonus` - `LiftTypeBonus` is: - `0.5` if `LiftType` is `Cable` - `0.1` if `LiftType` is `Launched` - `0.0` otherwise Return a list of strings in the same order as the input, where each string is formatted as: `"Overall: <score>"` The score should be rounded to one decimal place. Assume the input strings are well-formed, numeric fields can be parsed as floating-point values, and any denominator used by the relevant formula is nonzero. Follow-up: design the solution so that adding new coaster types or changing scoring rules does not require modifying the core processing loop.

Quick Answer: This question evaluates proficiency in string parsing, floating-point arithmetic, conditional logic, and designing extensible rule-based scoring systems.

Part 1: Compute Roller Coaster Overall Scores

You are given a list of roller coaster descriptions. Each description is a string in the format '<CoasterType> <MaxSpeed> <BumpsPerSecond> <LiftType>'. CoasterType is one of Wooden, Steel, or Suspended. For each coaster, compute OverallScore = ScaleFactor * ComfortScore * MaxSpeed, where Wooden uses scale 1.0 and comfort min(1.0, 1.0 / BumpsPerSecond), Steel uses scale 2.0 and comfort min(1.0, 5.0 / MaxSpeed), and Suspended uses scale 0.5 and comfort min(1.0, 1.0 / BumpsPerSecond) plus a lift bonus of 0.5 for Cable, 0.1 for Launched, and 0.0 otherwise. Return the scores in the same order, formatted as 'Overall: <score>' with the score rounded to one decimal place.

Constraints

  • 0 <= len(descriptions) <= 10^4
  • Each description is well-formed and contains exactly 4 space-separated tokens.
  • Numeric fields can be parsed as floats.
  • Any denominator used by the relevant formula is nonzero.

Examples

Input: ['Wooden 4 2 Chain', 'Steel 20 0 Cable', 'Suspended 2 0.5 Cable']

Expected Output: ['Overall: 2.0', 'Overall: 10.0', 'Overall: 1.5']

Explanation: Wooden -> 1.0 * min(1, 1/2) * 4 = 2.0; Steel -> 2.0 * min(1, 5/20) * 20 = 10.0; Suspended -> 0.5 * (min(1, 1/0.5) + 0.5) * 2 = 1.5.

Input: ['Suspended 10 4 Launched']

Expected Output: ['Overall: 1.8']

Explanation: Comfort = min(1, 1/4) + 0.1 = 0.35, so score = 0.5 * 0.35 * 10 = 1.75, which rounds to 1.8.

Input: []

Expected Output: []

Explanation: Edge case: an empty input list should return an empty output list.

Input: ['Wooden 7.5 0.25 Chain', 'Steel 3 99 Cable']

Expected Output: ['Overall: 7.5', 'Overall: 6.0']

Explanation: For both coasters, the comfort score is capped at 1.0 by the min operation.

Hints

  1. Parse each description into four pieces, then branch on coaster type to choose the correct comfort formula.
  2. Use formatting like f'Overall: {score:.1f}' so the result is rounded to one decimal place.

Part 2: Build an Extensible Roller Coaster Scoring Engine

You are given roller coaster descriptions and a rules dictionary. Each description is still a string in the format '<CoasterType> <MaxSpeed> <BumpsPerSecond> <LiftType>'. The rules dictionary is keyed by coaster type. Each rule contains 'scale' and 'comfort_model', plus model-specific fields. Supported comfort models are: 'inverse_bumps' -> min(1.0, base / bumps), 'inverse_speed' -> min(1.0, base / speed), 'inverse_bumps_plus_lift_bonus' -> min(1.0, base / bumps) + lift_bonus.get(lift_type, 0.0), and 'constant' -> value. For each coaster, compute score = scale * comfort * speed and return formatted strings 'Overall: <score>' rounded to one decimal place. The solution should be data-driven so new coaster types or changed parameters can be handled by changing only the rules input, not the core processing loop.

Constraints

  • 0 <= len(descriptions) <= 10^4
  • Every coaster type appearing in descriptions exists in rules.
  • Supported comfort_model values are 'inverse_bumps', 'inverse_speed', 'inverse_bumps_plus_lift_bonus', and 'constant'.
  • Descriptions are well-formed and numeric fields can be parsed as floats.
  • Any denominator used by the relevant formula is nonzero.

Examples

Input: (['Wooden 4 2 Chain', 'Steel 20 0 Cable', 'Suspended 2 0.5 Cable'], {'Wooden': {'scale': 1.0, 'comfort_model': 'inverse_bumps', 'base': 1.0}, 'Steel': {'scale': 2.0, 'comfort_model': 'inverse_speed', 'base': 5.0}, 'Suspended': {'scale': 0.5, 'comfort_model': 'inverse_bumps_plus_lift_bonus', 'base': 1.0, 'lift_bonus': {'Cable': 0.5, 'Launched': 0.1}}})

Expected Output: ['Overall: 2.0', 'Overall: 10.0', 'Overall: 1.5']

Explanation: These rules reproduce the original three coaster types using a data-driven configuration.

Input: (['Hybrid 12 8 Magnetic'], {'Hybrid': {'scale': 1.5, 'comfort_model': 'constant', 'value': 0.8}})

Expected Output: ['Overall: 14.4']

Explanation: A brand new type is added only by changing the rules data: 1.5 * 0.8 * 12 = 14.4.

Input: (['Wooden 10 4 Chain'], {'Wooden': {'scale': 2.0, 'comfort_model': 'inverse_bumps', 'base': 2.0}})

Expected Output: ['Overall: 10.0']

Explanation: Changing the scale and base values in the rule changes the score without any change to the loop logic.

Input: ([], {'Wooden': {'scale': 1.0, 'comfort_model': 'inverse_bumps', 'base': 1.0}})

Expected Output: []

Explanation: Edge case: no coasters means no output strings.

Input: (['Suspended 6 2 Chain'], {'Suspended': {'scale': 0.5, 'comfort_model': 'inverse_bumps_plus_lift_bonus', 'base': 1.0, 'lift_bonus': {'Cable': 0.5, 'Launched': 0.1}}})

Expected Output: ['Overall: 1.5']

Explanation: Chain is not present in lift_bonus, so the bonus defaults to 0.0.

Hints

  1. Keep the parsing loop generic, and move each comfort formula into a handler selected by comfort_model.
  2. A dispatch table from comfort_model to function is a clean way to make the design extensible.
Last updated: May 7, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Write Transaction Analytics SQL Queries - Zoox (medium)
  • Write SQL revenue and anomaly queries - Zoox (medium)
  • Can a Car Meet a Truck? - Zoox (hard)
  • Choose fastest way to transfer 2 TB - Zoox (easy)