Skip to content

klucar/bowling

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

This is a simple project to display some coding knowledge for a job interview. My solution generates an upper diagonal matrix "A" that can be used to quickly generate the bowler's final score.  If the bowler throws 15 balls in a game, "A" will be a 15x15 matrix, and F is a 15x1 matrix containing the number of pins knocked down with each throw. The matrices are mutiplied with a 1x15 matrix "J" consisting of all ones. The final score is the product JxAxF .

Problem Description

Create a program, which, given an integer array of a valid sequence of throws for 

one game of American Ten-Pin Bowling, produces the total score for the game.

Stuff That’s Out of Scope

Here are some things that the program does not need to do (today):

 check for valid throws (like scores that add to 11)

 check for the correct number of throws and frames

 provide any intermediate scores – it only has to provide the final score

 parse string input – your inputs should be an int[]

The Rules

To briefly summarize the scoring for this form of bowling:

 One game of bowling is made up of ten frames.

 In each frame, the bowler has two throws to knock down all the pins.

 Possible results for a frame:

o Strike (‘X’): the bowler knocks down all 10 pins on the first throw.

The frame is over early. The score for the frame is 10 plus the total pins 

knocked down on the next two throws.

o Spare (‘/’): the bowler knocks down all 10 pins using two throws.

The score for the frame is 10 plus the number of pins knocked down on 

the next throw.

o Open frame: the bowler knocks down less than 10 pins with his two 

throws. The score for the frame is the total number of pins knocked 

down.

 The game score is the total of all frame scores. 

 Special rules for the 10th

frame:

o A strike in the tenth frame gives the bowler two bonus throws, to fill out 

the scoring formula for the last frame.

o A spare in the tenth frame gives the bowler one bonus throw, to fill out 

the scoring formula for the last frame.

o These throws count as part of the 10th

frame.

o The process does not repeat – for example, knocking down all 10 pins 

on a bonus throw does not provide any additional bonus throws.

Examples

 X-X-X-X-X-X-X-X-X-X-XX = (10+10+10) + (10+10+10) + (10+10+10) + 

(10+10+10) + (10+10+10) + (10+10+10) + (10+10+10) + (10+10+10) + 

(10+10+10) + (10+10+10) = 300

 45-54-36-27-09-63-81-18-90-72 = 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 = 90

 5/-5/-5/-5/-5/-5/-5/-5/-5/-5/-5 = (10+5) + (10+5) + (10+5) + (10+5) + 

(10+5) + (10+5) + (10+5) + (10+5) + (10+5) + (10+5) = 150

About

A Bowling Calculator

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages