You are to develop a program that takes as input the scorecard filled out by Bob and that produces as output the correct scorecard.

Similar documents
Handicap Differential = (Adjusted Gross Score - USGA Course Rating) x 113 / USGA Slope Rating

Broken Calculators. Prepared by Daniel Finkel for the Julia Robinson Festival

Indiana Academic 22 nd Annual M.A.T.H. Bowl. Invitational January 22 Feb. 3, Begin Practice Round

Indiana Academic 22 nd Annual M.A.T.H. Bowl

Problem A: Driving Around the Beltway.

Pegas 4000 MF Gas Mixer InstructionManual Columbus Instruments

ROUND TOSS-UP: What is the square root of one million? (1000) (10 points) BONUS: How many zeros are at the end of ?

1. (a) (i) 0.049, 0.39, 0.4, 0.409, B1 for correct order. (b) B1 for (a) B1 for (b) B1 for 0.08.

WOMEN S NINE HOLE GOLF ASSOCIATION

Iteration: while, for, do while, Reading Input with Sentinels and User-defined Functions

Regional Final. Supervisor s Booklet

TASK KINO ZIMA KEKS OGRADA BROJ KRIPTOGRAM. keks.pas keks.c keks.cpp. time limit 1 second 1 second 1 second 1 second 1 second 1 second

Club s Homepage Use this feature to return the club s website.

INSTRUCTION FOR FILLING OUT THE JUDGES SPREADSHEET

Summer Work. 6 th Grade Enriched Math to 7 th Grade Pre-Algebra

(a) Monday (b) Wednesday (c) Thursday (d) Friday (e) Saturday

Summary of SAGA Handicap Manual

Welcome to Ladies Grand Niners! We are a Sun City Grand ladies nine-hole golf league.

TASK 4.2.1: "HAMILTON'S ROBOT" ==============================

A Hare-Lynx Simulation Model

Sum Fun Tournament Meeting (Multiple Topics)

Edexcel GCSE. Mathematics A 1387 Paper 5523/03. November Mark Scheme. Mathematics A 1387

INSTITUTE AND FACULTY OF ACTUARIES. Curriculum 2019 AUDIT TRAIL

USER GUIDE USER GUIDE

2018 School Competition Sprint Round Problems 1 30

THE USGA HANDICAP SYSTEM. Reference Guide

Number & Place Value: Read, write, order and compare numbers to at least 1,000,000 and determine the value of each digit.

Chapter 2 Displaying and Describing Categorical Data

Number Sense Performance Task: Par The Mini-Golf Way! LEVEL 1 Anchor

OKLAHOMA MATH DAY. Instructions for the SOONER MATH BOWL

EVENTS TRADITIONAL EVENTS UNIFIED EVENTS

NCSS Statistical Software

Summary of SAGA Handicap Manual

Content Design Structure, Scope & Sequence of Mathematics Content Addressed Within Numbers Up! Volcanic Panic

Internet Technology Fundamentals. To use a passing score at the percentiles listed below:

Donaghadee Golf Club Bye-Laws

2015 π Math Contest. Individual Round SOLUTIONS

Baseball Scorekeeping for First Timers

ScoreKeeper tm. ~ Software for Golf ~ for Microsoft Windows 98 through Windows 7. User's Guide

Navigate to the golf data folder and make it your working directory. Load the data by typing

23 August 2016 Page: 1

+TABLE OF CONTENTS RULE # PAGE # SCHEDULE 3 2. PLAYER ELIGIBILITY CLUB RESPONSIBILITIES CLUB OPTIONS. 3

Finding the optimal trajectory for your driver

b) (2 pts.) Does the study show that drinking 4 or more cups of coffee a day caused the higher death rate?

SECTION 1. READING AND WRITING NUMBERS PLACE VALUE

PLAYING CONDITIONS. 4. Each team is allowed to replace a player with another player ONLY ONCE during the competition, subject to rule 3.

1. What is the SGA Centralised Handicapping System (CHS)?

1.862 x x 10. The 'Estimation' Game. April 03, SB Multiplying and Dividing Decimals.notebook. MINDS ON (Elicit & Engage)

HW #5: Digital Logic and Flip Flops

ORF 201 Computer Methods in Problem Solving. Final Project: Dynamic Programming Optimal Sailing Strategies

A QUICK GUIDE TO THE CONGU HANDICAPPING SYSTEM FOR PLAYERS

Name: Class: Date: (First Page) Name: Class: Date: (Subsequent Pages) 1. {Exercise 5.07}

THIS MANUAL HAS BEEN PREPARED FOR THE PURPOSE OF ASSISTING IN THE INSTALLATION AND MAINTENANCE OF THE MINIMAX GOLF HANDICAPPING SYSTEM.

GIRLS TEAM TOURNAMENT Hole Tournament Thursday October 4, 2018 The Country Club Meadville, PA 10 AM Shotgun Start

Student Resource / Program Workbook INTEGERS

Fantasy Baseball Filename: baseball

DANFORTH SENIOR MEN'S GOLF LEAGUE RULES OF PLAY 2018 Membership Eligibility: Age 55 and older

FRA SUMMER MATH 2017 Math Course 3

At each type of conflict location, the risk is affected by certain parameters:

FUNCTIONAL SKILLS MATHEMATICS (level 1)

UAB MATH-BY-MAIL CONTEST, 2004

The 19 th hole - 18 Card Micro Golf game. # Of Players: 1 or 2 players. Game time: min per game if a 2 player game.

Annanhill Golf Course Off Peak Peak. Adult Concession Day Ticket Locker Hire Golf Buggy Hire 18.

Unit 1 Summary. License Math: Basic Math in Real Estate. Converting fractions to decimals

A. The name of Scratch Ticket Game No is DOUBLE BONUS CROSSWORD. The play style is crossword.

Web Inquiry Shot Detail Export

Background Information. Project Instructions. Problem Statement. EXAM REVIEW PROJECT Microsoft Excel Review Baseball Hall of Fame Problem

Club s Homepage Welcome Club Calendar Logout Add a Request Play Date Requested Time Hole Selection # of Tee Times Break Link

11 TH ANNUAL MATHLETES IN ACTION

2015 FHSPS Playoff May 16, 2015 Online

STATIONARY SPRINKLER IRRIGATION SYSTEM

Specifications and information are subject to change without notice. Up-to-date address information is available on our website.

Problem Solving. 1. If

Deer Population Student Guide

Water Waves in an Electric Sink

The next criteria will apply to partial tournaments. Consider the following example:

Rules for the Mental Calculation World Cup 2018

Secretary: Steve Harrod PO Box 2176, Wollongong, NSW 2500 m e.

Extending the Number System

INTRODUCTION Page 2 SETTINGS

REAL LIFE GRAPHS M.K. HOME TUITION. Mathematics Revision Guides Level: GCSE Higher Tier

Mark Scheme (Results) Summer 2009

Chapter 5 - Probability Section 1: Randomness, Probability, and Simulation

Guidelines for Using the UMTRI ATD Positioning Procedure for ATD and Seat Positioning

Club Multiple Teams and Suggested Movements

Using Markov Chains to Analyze a Volleyball Rally

1.1 description. Golf consists of playing a ball from the teeing ground into the hole according to the rules.

ELIMINATOR INSTRUCTIONS Table of Contents

ROULETTE RED OR BLACK? Play to find out. PLAYER S GUIDE

Method 1: Circuit Race Score Sheet instructions

The Coach then sorts the 25 players into separate teams and positions

Dynamic Programming: The Matrix Chain Algorithm

Bouncing Ball A C T I V I T Y 8. Objectives. You ll Need. Name Date

LIMERICK TIMES GOLF HUMOR SORRY ABOUT THAT DOUBLE, HERE LIGHTEN UP APRIL 2018 THE GOLF SEASON IS UPON US

Using a double entry table "Temperature graph"

CHOOSE THE RIGHT BALL FOR YOUR GAME! 2017 Golf Ball Marketing

GOLF. The following events can be offered at County, Area and State Level competitions:

A fast and complete convection scheme for ocean models. Stefan Rahmstorf. Institut für Meereskunde Kiel Germany. published in. Ocean Modelling Nr.

Lab 5: Descriptive Statistics

WINNETKA GOLF CLUB OUTING REQUEST Mail Outing Request to 1300 Oak Street. Winnetka, IL or E mail to

Transcription:

Problem 1: What s My Score? Ann, Bob, Carol, and Dave played nine holes of golf together. On the first hole, Ann teed off first, followed by Bob, then Carol, and, finally, Dave. At each subsequent hole, the order in which they teed off was in accord with the usual golfing convention, which is as follows: The golfer with the lowest score on the previous hole tees off first, followed by the golfer with the second lowest score, etc., etc. Golfers having equal scores on the previous hole tee off in the same relative order as they did on the previous hole. A scorecard has four columns (one for each golfer) and nine rows (one for each of the nine holes). The score achieved by a given golfer on a given hole is to be recorded in the row corresponding to that hole in the column corresponding to that golfer. Bob was responsible for keeping score. He was well aware that the scores achieved by the golfers on a given hole were to be recorded on the scorecard in the row corresponding to that hole. Unfortunately, he did not possess a proper understanding of the purpose of the four columns on the scorecard! He thought that the first column was for recording the score of the golfer who teed off first on the given hole, the second column was for recording the score of the golfer who teed off second on the given hole, etc., etc. Thus, in each row of the scorecard, Bob recorded the correct scores, but (usually, at least) in the wrong columns. You are to develop a program that takes as input the scorecard filled out by Bob and that produces as output the correct scorecard. As illustrated in the sample execution below, your program should prompt the user to enter Bob s original scorecard, one row at a time. The numbers entered by the user shall be separated from each other by at least one space. After consuming all the input, your program should display the correct scorecard, with one column showing hole numbers and four subsequent columns showing the scores of Ann, Bob, Carol, and Dave, in that order. Each golfer s total score (the sum of the scores on the nine holes) should be displayed at the bottom of her/his column. 1

Sample execution: ============================================================== Enter hole 1 from original scorecard: 4 6 5 5 Enter hole 2 from original scorecard: 5 4 6 4 Enter hole 3 from original scorecard: 4 3 6 5 Enter hole 4 from original scorecard: 4 4 3 5 Enter hole 5 from original scorecard: 5 3 4 4 Enter hole 6 from original scorecard: 5 5 5 5 Enter hole 7 from original scorecard: 4 4 4 4 Enter hole 8 from original scorecard: 4 4 4 4 Enter hole 9 from original scorecard: 2 4 3 4 Corrected scorecard: 1 4 6 5 5 2 5 4 4 6 3 6 3 4 5 4 5 4 4 3 5 4 3 4 5 6 5 5 5 5 7 4 4 4 4 8 4 4 4 4 9 3 2 4 4 ------------------------------------ Totals 40 35 38 41 2

Problem 2: Spiral of Squares Imagine a grid whose cells have been numbered, starting at zero, in the outwardly-spiraling pattern illustrated below. Imagine that the spiral extends out to infinity. 56 57 58 59 60 61 62 63 64 55 30 31 32 33 34 35 36 65 54 29 12 13 14 15 16 37 66 53 28 11 2 3 4 17 38 67 52 27 10 1 0 5 18 39 68 51 26 9 8 7 6 19 40 69 50 25 24 23 22 21 20 41 70 49 48 47 46 45 44 43 42 71 80 79 78 77 76 75 74 73 72 You are to develop a program that, given as input two nonnegative integers j and k, with neither exceeding 1000, outputs the distance on the grid between the cells numbered j and k. By distance between two cells we mean the fewest number of steps by which it is possible to get from one to the other, assuming that in each step we can move one position in a horizontal or vertical (but not diagonal) direction. End of input is signaled when both inputs are zero. Sample execution: ==================================== Enter two inputs: 15 42 Distance: 7 Enter two inputs: 132 132 Distance: 0 Enter two inputs: 37 25 Distance: 10 Enter two inputs: 0 0 3

Problem 3: Hill Removal A sequence of three or more integers whose members are in strictly increasing or strictly decreasing order is called a hill. (For example, 2, 5, 8, 9 and 5, 3, 1 are hills. However, 4, 7, 7, 12 is not, because its 3rd member is no greater than its 2nd.) A sequence of integers that is not itself a hill may contain one or more contiguous subsequences that are hills. For example, the sequence 5, 3, 5, 9, 7, 4, 1, 2 contains as subsequences the hills 3, 5, 9 and 9, 7, 4 and 7, 4, 1 and 9, 7, 4, 1. Develop a program that, given as input a sequence of integers, rearranges them so that the resulting sequence contains no contiguous subsequences that are hills. For each input sequence, the user shall enter its length followed by the sequence itself (as illustrated below). End of input is signaled by a sequence length of zero. The user shall not enter a sequence of length exceeding twenty. Sample execution: ============================================ Enter sequence length: 9 Enter element 1: 5 Enter element 2: 8 Enter element 3: 5 Enter element 4: 3 Enter element 5: 7 Enter element 6: 9 Enter element 7: 12 Enter element 8: 6 Enter element 9: 8 5 8 3 7 5 9 6 12 8 Enter sequence length: 6 Enter element 1: 1 Enter element 2: 2 Enter element 3: 3 Enter element 4: 4 Enter element 5: 5 Enter element 6: 6 1 3 2 5 4 6 Enter sequence length: 0 4

Problem 4: Number Representation in the Factorial Base For a positive integer m, we define m! = 1 2 3 m. That is, m! is the product of the positive integers 1 through m. (This is the well known factorial function.) Interestingly, for every positive integer k there exists a unique sequence of nonnegative integers d 1, d 2,..., d n, (where d j j for all j) such that k = d 1 1! + d 2 2! + d 3 3! + + d n n! In the factorial base number system, the number k would be represented by the sequence of digits d n d n 1 d 2 d 1. For example, the number that we express as 523 in the standard decimal number system would be expressed by 41301 in the factorial base, corresponding to the fact that 523 = 1 1! + 0 2! + 3 3! + 1 4! + 4 5! = 1 + 0 + 18 + 24 + 480 Develop a program that takes as input a positive integer and that produces as ouput its representation in the factorial base number system, as illustrated below. (Note: The digits in the output may be separated by spaces.) End of input is signaled by the user entering zero. You may assume that the user shall enter no input value whose factorial base representation requires more than seven digits. Hint: By repeatedly applying the distributive property of multiplication over addition, you will find that the number k = d 1 1! + d 2 2! + + d n n! can also be written as follows: k = d 1 + 2(d 2 + 3(d 3 + 4(d 4 + + (n 1)(d n 1 + n d n ) ) Thus, for instance, to determine the digit d 1, it suffices to take the remainder of the division k/2. The remaining digits can be determined by carrying out more divisions, using the same idea. End of Hint. Sample execution: ============================== Enter input: 1811 230121 Enter input: 0 5

Problem 5: No Hassle Auto Insurance The No Hassle Auto Insurance company believes that everyone deserves a second chance, and therefore it does not raise the rate of a driver after he is involved in his first accident or receives his first ticket. However, the rate will increase for a driver involved in a second accident or receiving a second ticket. A driver whose number of accidents plus tickets exceeds four is uninsurable. The basic formula for the rate charged by the No Hassle company is r = 0.02 c a! t! y where c stands for the value of the car (see below), a stands for number of accidents, t stands for number of tickets received, and y stands for the age multiplier (see below). Recall that 0! = 1 and, for m > 0, m! = 1 2 3 m (i.e., the product of the integers 1 through m). This is the well known factorial function. To calculate c (the value of the car), the purchase price and age of the car are required. Specifically, the value of a car of age zero is its purchase price. The value of a car of age greater than zero is 90 percent of its previous year s value. To calculate y, we need the driver s age. Specifically, for a driver between the ages of 16 and 24, y = 3. For ages 25 through 34, y = 1.5. For ages 35 through 44, y = 1. For ages, 45 through 64, y = 1.5. For ages 65 and above, y = 3. Develop a program that takes as input the purchase price and age of a car, the age of its driver, the number of accidents in which the driver has been involved, and the number of tickets the driver has received. (All these will be nonnegative integers.) As output, the program should display the insurance rate for the driver, accurate to at least two places after the decimal point, or else a message indicating that she is uninsurable. End of input is signaled by the user entering zero for the purchase price of the car. 6

Sample execution: ============================================ Enter purchase price of car: 20000 Enter age of car: 3 Enter age of driver: 26 Enter number of accidents: 0 Enter number of tickets: 2 Rate: 874.80 Enter purchase price of car: 12000 Enter age of car: 1 Enter age of driver: 19 Enter number of accidents: 1 Enter number of tickets: 2 Rate: 1296.00 Enter purchase price of car: 34000 Enter age of car: 6 Enter age of driver: 80 Enter number of accidents: 1 Enter number of tickets: 4 Driver is uninsurable Enter purchase price of car: 0 7

Problem 6: Lax Security The Lax Hazardous Waste Company must maintain a certain level of security at its plant because of the nature of the materials handled there. The main door to the plant has a keypad similar to the one shown below. To open the door, an employee must first enter her five-digit personal identification number (PIN). If the PIN is valid, the door opens. Otherwise, it does not. 1 2 3 4 5 6 7 8 9 +---+ 0 +---+ However, Bocefus Lax, the company owner, is a nice lady who doesn t like to burden her employees unnecessarily. The digits on the keypad are close together and employees often enter their PIN incorrectly by pressing an adjacent button instead of the intended one. Therefore, she wants to modify the access system so that it allows an employee to open the door even if the PIN they enter is slightly incorrect. Specifically, Bocefus is willing to assume that the person using the keypad is one of her employees if the number the person enters has no more than one digit that is off-by-one from some valid PIN. Here, off-by-one means that, with respect to the keypad, the incorrect digit is either immediately above, below, to the right of, or to the left of the correct digit. (For example, the digits that are off-by-one from 4 are 1, 5, and 7.) Develop a program that takes as input a list of valid PINs followed by a list of five-digit numbers. For each number in the latter list, the program is to report whether it is accepted or rejected. For each accepted number, the program reports which valid PIN it matches (exactly or approximately). Note that a number entered on the keypad could match more than one valid PIN. For example, the PIN 22222 is off-by-one from 21222, 52222, 22223, and many others. If a number entered on the keypad matches a valid PIN exactly, that PIN should be identified. If the number matches no valid PIN exactly, but approximately matches some valid PIN, report the first such valid PIN in the list. End of input is signaled by the user entering all zeros. 8

Sample execution: =========================================== Enter number of valid PINs: 4 Enter valid PIN number 1: 10360 Enter valid PIN number 2: 36243 Enter valid PIN number 3: 39491 Enter valid PIN number 4: 26543 Enter a number: 39491 Matches 39491 Enter a number: 36491 Matches 39491 Enter a number: 14543 No matches Enter a number: 26243 Matches 36243 Enter a number: 00000 9