Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The first parameter represents a direction ( the value of one of the constants UP , DOWN, FORWARD and BACKWARD ) and the second represents

The first parameter represents a direction (the value of one of the constants UP, DOWN, FORWARD and BACKWARD) and the second represents the number of words left to be found before this guess. Return the points that would be earned if we were to now find some word in this direction.
If there are THRESHOLD or more words left to be found, the number of points for a correct guess is simply THRESHOLD times the factor for the appropriate direction. If the number of words left to be found is less than THRESHOLD, then the total points earned for a correct guess is two times THRESHOLD minus the number of left to be found before the guess, all multiplied by the factor for the appropriate direction. On top of that there is an extra bonus of BONUS points for finding the last word.
For example, suppose there are five words left to be found, and we correctly guess a backward word. Then the number of points for the correct guess is:
THRESHOLD * BACKWARD_FACTOR =15.
If there were only two words left to be found, and we correctly guess a backward word, then the number of points for the correct guess is:
(2* THRESHOLD -2)* BACKWARD_FACTOR =24 points.
If there was only one word left to be found, and we correctly guess a backward word, then the number of points for the correct guess is:
(2* THRESHOLD -1)* BACKWARD_FACTOR + BONUS =39 points.
get_points(str, int)-> int

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Students also viewed these Databases questions