PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates a candidate's ability to implement rule-based scoring logic, array processing, and stateful iteration to correctly aggregate frame scores in ten-pin bowling.

  • medium
  • Tradedesk
  • Coding & Algorithms
  • Software Engineer

Calculate Bowling Game Score

Company: Tradedesk

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

Implement a function that calculates the total score of a complete ten-pin bowling game. Input: a list of integers `rolls`, where each integer is the number of pins knocked down by one roll, in chronological order. Scoring rules: - A game has 10 frames. - In frames 1 through 9: - If the first roll knocks down all 10 pins, it is a strike. The frame score is `10 + the next two rolls`. - Otherwise, the player rolls a second time. - If the two rolls in the frame sum to 10, it is a spare. The frame score is `10 + the next roll`. - Otherwise, the frame score is the sum of the two rolls. - In the 10th frame: - The player always rolls at least two balls unless the first roll is a strike. - If the player gets a strike or spare in the 10th frame, they receive one or two bonus rolls as needed, so the 10th frame may contain up to three rolls. Return the final total score. Example: ```text Input: [10, 7, 3, 9, 0, 10, 0, 8, 8, 2, 0, 6, 10, 10, 10, 8, 1] Output: 167 ``` You may assume the input represents a valid complete game.

Quick Answer: This question evaluates a candidate's ability to implement rule-based scoring logic, array processing, and stateful iteration to correctly aggregate frame scores in ten-pin bowling.

Implement a function that calculates the total score of a valid, complete ten-pin bowling game. You are given the rolls in chronological order, where each roll is the number of pins knocked down. The game has 10 frames. In frames 1 through 9, a strike scores 10 plus the next two rolls, a spare scores 10 plus the next roll, and an open frame scores the sum of its two rolls. In the 10th frame, bonus rolls may appear if the player rolls a strike or spare. Return the final total score. You may assume the input represents a valid complete game.

Constraints

  • rolls represents a valid complete ten-pin bowling game
  • 11 <= len(rolls) <= 21
  • 0 <= rolls[i] <= 10
  • The game contains exactly 10 frames, including any valid bonus rolls in the 10th frame

Examples

Input: ([10, 7, 3, 9, 0, 10, 0, 8, 8, 2, 0, 6, 10, 10, 10, 8, 1],)

Expected Output: 167

Explanation: The game includes strikes, spares, and open frames. Applying strike and spare bonuses over all 10 frames gives a total score of 167.

Input: ([10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],)

Expected Output: 300

Explanation: A perfect game has 12 strikes. Each frame scores 30, for a total of 300.

Input: ([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],)

Expected Output: 0

Explanation: No pins are knocked down in any roll, so every frame scores 0.

Input: ([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],)

Expected Output: 20

Explanation: There are 10 open frames, each worth 2 points.

Input: ([5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],)

Expected Output: 150

Explanation: Every frame is a spare with a bonus roll of 5, so each frame scores 15.

Hints

  1. Process exactly 10 frames, while keeping an index into the rolls list.
  2. For strikes and spares, the bonus rolls are already present later in the rolls list, so you can look ahead from the current index.
Last updated: Jun 13, 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

  • Implement a Cloud Storage Service - Tradedesk (medium)
  • Design a time-travel key-field store with TTL - Tradedesk (medium)
  • Implement monotonic-array linear interpolation - Tradedesk (easy)