A “Re-Worked” Number Guesser

In a previous project, my Computer Science 1 students were assigned the task of creating a “number guesser” in Python that could “guess” the number selected by the user based upon the user answering if the guess was too high or too low. To accomplish this task, we created a program similar to the following:

#Programmer Name: Eric Evans
#Program Name: Number Guesser
#Program Description: A program that will "guess" the number selected by the user that is between 1 and 100 using a series of questions.
runAgain = "Y"
high = 100
low = 1
guess = (high + low) / 2
#guess = random.randint(low, high)
while (runAgain =="Y"):
  correct = "N"
  guessCount = 1
  print("Let's play a guessing game")
  print("Pick a whole number between 1 and 100")
  print("You have to tell me if I get it correct or if I'm too high or too low.")
  print("Let's get started.")
  print("")
  while (correct == "N"):
    guess = int(guess)
    guessAsString = str(guess)
    print("Is Your Number " + guessAsString + "?")
    response = input("[C]orrect / [L]ow / [H]igh")
    response = response.upper()
    if (response == "C"):
      guessCountAsString = str(guessCount)
      print("Yay! I got it in " + guessCountAsString + " guesses!")
      correct = "Y"
    elif (response == "L"):
      print("Too Low Huh?")
      low = guess + 1
      guess = (high + low) / 2
      guessCount = guessCount + 1
    elif (response == "H"):
      print("Too High Huh?")
      high = guess - 1
      guess = (high + low) / 2
      guessCount = guessCount + 1
  print("Would You Like to Run the Program Again?")
  runAgain = input("[Y]es or [N]o")
  runAgain = runAgain.upper()
print("Thank you for playing.")
print("Exiting Program - Goodbye")

Now, for the second version of this program, the roles will be flipped. The computer will now be selecting a whole number between 1 and 100 and the user will be attempting to guess the number.

Here is an basic example of what a possible solution could look like:

#Programmer Name: Eric Evans
#Program Name: Number Guesser - Take 2
#Program Description: A program that will select a random number and have the user attempt to guess the chosen number.
import random
#Imports the random library to allow for random number generation
runAgain = "Y"
#Declares and initializes the variable runAgain with a value of "Y" 
high = 100
#Declares and initializes the variable high with a value of "100"
low = 1
#Declares and initializes the variable low with a value of "1"
while (runAgain =="Y"):
#Starts a while loop to allow the program to run again.
  computerNumber = random.randint(low, high)
  #Declares and initializes the variable computerNumber with a randomly selected integer between the value of the variables high and low.
  correct = "N"
  #Declares and initializes the variable correct with a value of "N"
  guessCount = 1
  #Declares and initializes the variable guessCount with a value of "1"
  print("Let's play a guessing game")
  #Outputs information to the screen for the user
  print("I am going to pick a whole number between 1 and 100")
  #Outputs information to the screen for the user
  print("After each guess, I will tell you if you are correct or if you're too high or too low.")
  #Outputs information to the screen for the user
  print("Let's get started.")
  #Outputs information to the screen for the user
  print("")
  #Visually breaks-up the information on the screen for the user
  while (correct == "N"):
    #Starts a nested while loop to allow the user to make more guesses until the variable correct is equal to "Y"
    guess = input("What Is Your Guess? ")
    #Declares and initializes variable guess with the value entered by the user from the keyboard
    guess = int(guess)
    #Casts the variable guess as an integer
    if (guess == computerNumber):
    #Starts a conditional if statement to address when the user guesses the correct number
      guessCountAsString = str(guessCount)
      #Declares and initializes variable guessCountAsString with the value of the variable guessCount cast as a string
      print("Wow! You guessed my number in " + guessCountAsString + " guesses!")
      #Outputs information to the screen for the user
      correct = "Y" #Sets the value of the variable correct to "Y" to exit the inner while loop
    elif (guess < computerNumber and (abs(computerNumber - guess) > (int(computerNumber * .15)))):
    #Starts a conditional else/if statement to address when the user guesses a number that is less than the number selected by the computer and is more than 15% of the value of the computerNumber away
      guessAsString = str(guess)
      #Declares and initializes variable guessAsString with the value of the variable guess cast as a string
      print("Your guess of "+ guessAsString + " is too low.")
      #Outputs information to the screen for the user
      print("Please try again.")
      #Outputs information to the screen for the user
      print("")
      #Visually break-up the information on the screen for the user between their guesses
      guessCount = guessCount + 1
      #Increments the value of the guessCount variable by 1
    elif (guess < computerNumber and (abs(computerNumber - guess) <= (int(computerNumber * .15)))):
    #Starts a conditional else/if statement to address when the user guesses a number that is less than the number selected by the computer and is less than or equal to 15% of the value of the computerNumber away
      guessAsString = str(guess)
      #Declares and initializes variable guessAsString with the value of the variable guess cast as a string
      print("Your guess of "+ guessAsString + " is too low.")
      #Outputs information to the screen for the user
      print("You are very close!!!")
      #Outputs information to the screen for the user
      print("Please try again.")
      #Outputs information to the screen for the user
      print("")
      #Visually break-up the information on the screen for the user between their guesses
      guessCount = guessCount + 1
      #Increments the value of the guessCount variable by 1
    elif (guess > computerNumber and (abs(computerNumber - guess) > (int(computerNumber * .15)))):
    #Starts a conditional else/if statement to address when the user guesses a number that is greater than the number selected by the computer and is more than 15% of the value of the computerNumber away
      guessAsString = str(guess)
      #Declares and initializes variable guessAsString with the value of the variable guess cast as a string
      print("Your guess of "+ guessAsString + " is too high.")
      #Outputs information to the screen for the user
      print("Please try again.")
      #Outputs information to the screen for the user
      print("")
      #Visually break-up the information on the screen for the user between their guesses
      guessCount = guessCount + 1
      #Increments the value of the guessCount variable by 1
    elif (guess > computerNumber and (abs(computerNumber - guess) <= (int(computerNumber * .15)))):
    #Starts a conditional else/if statement to address when the user guesses a number that is greater than the number selected by the computer and is less than or equal to 15% of the value of the computerNumber away
      guessAsString = str(guess)
      #Declares and initializes variable guessAsString with the value of the variable guess cast as a string
      print("Your guess of "+ guessAsString + " is too high.")
      #Outputs information to the screen for the user
      print("You are very close!!!")
      #Outputs information to the screen for the user
      print("Please try again.")
      #Outputs information to the screen for the user
      print("")
      #Visually break-up the information on the screen for the user between their guesses
      guessCount = guessCount + 1
      #Increments the value of the guessCount variable by 1
  print("Would You Like to Run the Program Again?")
  #Outputs information to the screen for the user
  runAgain = input("[Y]es or [N]o")
  #Sets the value of the variable runAgain to the keyboard input received to allow user to repeat program or exit the outer-loop
  runAgain = runAgain.upper()
  #Sets the value of the variable runAgain to upper-case
print("Thank you for playing.")
#Outputs information to the screen for the user
print("Exiting Program - Goodbye")
#Outputs information to the screen for the user

As you can see, this version of the program also provides “encouragement” as you close-in on the selected number. Once you are within 15% of that number on the number-line you are told that you are very close.

Projected Grades – 6 Weeks to Go

We are now in the final 6-week stretch of the 2017/2018 school year! I have been running various projections for end-of-semester and end-of-year grades.

Principles of Applied Engineering

Projected Year - 6 Weeks - PAE(1)
Projected Year – 6 Weeks – PAE (1st Period)
Projected Year - 6 Weeks - PAE(5)
Projected Year – 6 Weeks – PAE (5th Period)
Projected Year - 6 Weeks - PAE(All)
Projected Year – 6 Weeks – PAE (All Sections)

With a total of 46 students enrolled in PAE, I can handle a failure rate of 4.35%. I not happy with that number as there is no excuse for failure of this class beyond simply not turning in assignments. Hopefully, these failing students will pull-up their grades in the final 6-weeks of instruction and be able to pass for the year.

Computer Science 1

Projected Year - 6 Weeks - CS1(2)
Projected Year – 6 Weeks – CS1 (2nd Period A Day)
Projected Year - 6 Weeks - CS1(4)
Projected Year – 6 Weeks – CS1 (4th Period A Day)
Projected Year - 6 Weeks - CS1(All)
Projected Year – 6 Weeks – CS1 (All Sections)

As you can see, my 4th Period A Day class has all A’s and B’s in the class. They have an overall class average of 93.59. In contrast, my 2nd Period A Day class has an overall class average of 85.15.

There are a total of 28 students currently enrolled in CS1. I am not satisfied with a failure rate of 7.1%. There is absolutely no excuse for this rate beyond students not submitting work. As with PAE, I am hopeful that the students pull their grades up and are able to pass for the year.

Python Number Guesser

Last year, I gave a problem in JAVA to create a number guesser. The idea was that the computer would randomly select a number and the user had to guess the number the computer had picked. http://funmultiplies.com/semester-review-computer-science

This year, in Computer Science 1, we have done a similar assignment in Python. However, in this version, the user is selecting the number and the computer has to “guess” the number the user selected.

On the first day of this project, students had to first choose a solving strategy. The two best strategies were called Hi/Lo Average and Hi/Lo Random.

The idea with both of these is that we ask the user to pick an integer (whole number) between 1 and 100.

With Hi/Lo Average, we take the average of the highest and lowest numbers, in this case 100 and 1 and we get 49. So, our first guess will be 49. If that is too low, then we move the lowest value up from 1 to 48. If 49 was too high, then we would move the highest value down from 100 to 50. We then make our second guess by taking the average of the new highest and lowest numbers. We repeat this process until we get to the number the user selected. The key advantage to this process is that we are guaranteed to solve the problem in 7 or fewer questions.

With Hi/Lo Random, we move the highest and lowest numbers identically to how we did in Hi/Lo Average after each incorrect guess, but we don’t take the average – we just select a random number between the highest and lowest numbers. This can potentially solve the problem very quickly or take considerably longer than Hi/Lo Average since you are entirely dependent upon what integers are selected by a random number generator.

Here is what a possible Hi/Lo Average solution looks like:

#Programmer Name: Eric Evans, M.Ed.
#Program Name: Number Guesser (Hi/Lo Average)
#Program Description: Uses a Hi/Lo Average algorithm to determine the number chosen the user.
#Algorithm: Starts with hi/lo or 100/1. Calculates average of hi/lo. Adjusts hi/lo accordingly after guess. Repeat calculation of average between new hi/lo. Repeat hi/lo adjustment...
#
correct = "N"
#Creates a variable named "correct" and sets the initial value as N
high = 100
#Creates a variable named "high" and sets the initial value as 100
low = 1
#Creates a variable named "low" and sets the initial value as 1
guessCount = 1
#Creates a variable named "guessCount" and sets the initial value as 1
guess = (high + low) / 2
#Creates a variable named "guess" and sets the initial value as the average of high and low
while (correct == "N"):
#Starts a loop that runs as long as the variable "correct" has a value of "N".
  guess = int(guess)
  #Casts the value of the variable "guess" as an integer. This truncates any decimals.
  guessAsString = str(guess)
  #Creates a variable named "guessAsString" and sets the initial value as the value of the variable named "guess" as a string.
  print ("Is Your Number " + guessAsString + "?")
  #Outputs the current "guess" for the user to see.
  response = input("[C]orrect  /  Too [L]ow  /  Too [H]igh")
  #Creates a variable named "response" and sets the initial value as the input from the keyboard.
  if (response == "C"):
  #Start of a conditional statement if the keyboard input is "C".
    guessCountAsString = str(guessCount)
    #Creates a variable named "guessCountAsString" and sets the initial value as the value of the variable named "guessCount" as a string.
    print("Yay! I got it in " + guessCountAsString + " guesses!")
    #Outputs the line displayed when the correct number is guessed.
    correct = "Y"
    #Changes the value of the variable named "correct" to "Y".
  elif (response == "L"):
  #Start of a conditional statement if the keyboard input is "L".
    print ("Too Low Huh?")
    #Outputs an acknowledgement to the user of their input.
    low = guess + 1
    #Changes the value of the variable named "low" to the value of the current guess + 1.
    guess = (high + low) / 2
    #Changes the value of the variable named "guess" to the value of the average of high and low.
    guessCount = guessCount + 1
    #Changes the value of the variable named "guessCount" by adding 1 to its existing value.
  elif (response == "H"):
  #Start of a conditional statement if the keyboard inputs is "H".
    print ("Too High Huh?")
    #Outputs an acknowledgement to the user of their input.
    high = guess - 1
    #Changes the value of the variable named "high" to the value of the current guess - 1.
    guess = (high + low) / 2
    #Changes the value of the variable named "guess" to the value of the average of high and low.
    guessCount = guessCount + 1
    #Changes the value of the variable named "guessCount" by adding 1 to its existing value.
print ("Exiting Program")
#Outputs a message letting the user they are exiting the program.

At the time of the first writing, I omitted the Hi/Lo Random solution as I wanted to see if my students could identify a key weakness inherent in that strategy. Here is a possible Hi/Lo Random solution (I discuss the weakness below):

#Programmer Name: Eric Evans, M.Ed.
#Program Name: Number Guesser (Hi/Lo Random)
#Program Description: Uses a Hi/Lo Random algorithm to determine the number chosen the user.
#Algorithm: Starts with hi/lo or 100/1. Selects a random number between hi/lo. Adjusts hi/lo accordingly after guess. Repeat selection of a random number between new hi/lo. Repeat hi/lo adjustment...
#
import random
correct = "N"
high = 100
low = 1
guessCount = 1
guess = random.randint(low, high)
while (correct == "N"):
  guess = int(guess)
  guessAsString = str(guess)
  print ("Is Your Number " + guessAsString + "?")
  response = input("[C]orrect  /  Too [L]ow  /  Too [H]igh")
  if (response == "C"):
    guessCountAsString = str(guessCount)
    print("Yay! I got it in " + guessCountAsString + " guesses!")
    correct = "Y"
  elif (response == "L"):
    print ("Too Low Huh?")
    low = guess + 1
    guess = random.randint(low, high)
    guessCount = guessCount + 1
  elif (response == "H"):
    print ("Too High Huh?")
    high = guess - 1
    guess = random.randint(low, high)
    guessCount = guessCount + 1
print ("Exiting Program")

If you played the Hi/Lo Random version of the game, you realized that there is nothing in the program to prevent the computer from randomly guessing the same number multiple times. This would need to be addressed by using a data structure to store the guesses and compare them as each subsequent guess was being made.

In addition, the odds are not “favorable” with a Hi/Lo Random game when compared to a Hi/Lo Average game.

Let’s say that the user has selected the number 21 as their number. Now, let’s look at the odds through each run compared side-by-side. I am going to use the random number generator from Google to generate the guesses for this example:

Run # Hi/Lo Average Hi/Lo Random
Guess Odds Guess Odds
1 50 1:100 16 1:100
2 25 1:49 48 1:30
3 12 1:23 17 1:29
4 18 1:11 27 1:8
5 21 1:1 25 1:6
6 N/A N/A 21 1:1

As you can see, with Hi/Lo Random, you are completely at the mercy of the numbers that are randomly generated whereas with Hi/Lo Average, you are guaranteed that your odds are twice as good after each guess.

Lesson Plans – Week of 2018-04-01

Lesson Plans – Week of 2018-04-01

  • (1 A/B) Principles of Applied Engineering
  • (2A) Computer Science 1
  • (2B) Computer Science 2
  • (3A) Robotics 1 / Robotics 2 / FTC 11242
  • (3B) Robotics 1 / Robotics 2 / FTC 12645
  • (4A) Computer Science 1
  • (5 A/B) Principles of Applied Engineering

Eric Evans – Planboard Week – 2018-04-01

Lesson Plans – Week of 2018-03-25

Lesson Plans – Week of 2018-03-25

  • (1 A/B) Principles of Applied Engineering
  • (2A) Computer Science 1
  • (2B) Computer Science 2
  • (3A) Robotics 1 / Robotics 2 / FTC 11242
  • (3B) Robotics 1 / Robotics 2 / FTC 12645
  • (4A) Computer Science 1
  • (5 A/B) Principles of Applied Engineering

Eric Evans – Planboard Week – 2018-03-25

Grade Calculator Programming – Day 1

Today, we started development of the minimum grade calculator in Computer Science 1.

#Programmer Name: Eric Evans, M.Ed.
#Program Name: Grade Calculator
#Program Description: Provides a minimum grade needed to get a C, B, or A in a given course for the semester and for the year.
#
print ("*********************************************************")
print ("** Welcome to the Grade Calculator                     **")
print ("**                                                     **")
print ("** You will need the following information to proceed: **")
print ("** - Fall Semester (S1) Grade                          **")
print ("** - 3rd Quarter (Q3) Grade                            **")
print ("**                                                     **")
print ("*********************************************************")
print ("")

Here, we started with our generic header and then a welcome screen that lets the user know what to expect and what they will need to proceed.

minC = 68.5
#Minimum average grade for "C" per Ferris ISD
minB = 79.5
#Minimum average grade for "B" per Ferris ISD 
minA = 89.5
#Minimum average grade for "A" per Ferris ISD

Here, are establishing the minimum graded needed to pass (minC), and get a B (minB) and an A (minA) according to our current grading guidelines.

s1 = float(input("What is your Fall Semester (S1) Grade? "))
#Ask for S1 input and cast as float
q3 = float(input("What is your 3rd Quarter (Q3) Grade? "))
#Ask for Q3 input and cast as float

Here, we are creating a variable named s1, which is going to hold the data entered by the user for their fall semester grade. We then create a variable named q3which is going to hold the data entered by the user for their 3rd quarter grade.

semMinC = ( ( ( 5 * minC ) - ( q3 * 2 ) ) / 3 )
#C Algorithm - Developed on 19-March-2018
semMinB = ( ( ( 5 * minB ) - ( q3 * 2 ) ) / 3 )
#B Algorithm - Developed on 19-March-2018
semMinA = ( ( ( 5 * minA ) - ( q3 * 2 ) ) / 3 )
#A Algorithm - Developed on 19-March-2018

Here is where we get to use the algorithm that was developed in the previous class ( Grade Calculator Algorithm Development ).

You will notice that it is being used 3 different times. Each case is separate to address the 3 different grade breaks (68.5, 79.5, and 89.5).

semMinCRounded = round(semMinC,2)
#Rounds minimum "C" output to 2 decimal points
semMinBRounded = round(semMinB,2)
#Rounds minimum "B" output to 2 decimal points
semMinARounded = round(semMinA,2)
#Rounds minimum "A" output to 2 decimal points

Here, we take the solution for each case and then round it to 2 decimal points.

semMinCString = str(semMinCRounded)
#Casts minimum "C" output as string
semMinBString = str(semMinBRounded)
#Casts minimum "B" output as string
semMinAString = str(semMinARounded)
#Casts minimum "A" output as string

Here, we are casting the rounded output as a string so we can use it in our output.

print("")
print("***********Q4 & SE2 MINIMUMS (SEMESTER)***********")
print("Min for C for Semester = " + semMinCString)
#Outputs minimum for "C" for semester
print("Min for B for Semester = " + semMinBString)
#Outputs minimum for "B" for semester
print("Min for A for Semester = " + semMinAString)
#Outputs minimum for "A" for semester

Here we finally provide our output for the use to see.

This code is deliberately broken-up so the students can see and manipulate the various components. (e.g., lines 24, 30, and 36).

Here is a consolidated version of the code that combines multiple steps:

#Programmer Name: Eric Evans, M.Ed.
#Program Name: Grade Calculator
#Program Description: Provides a minimum Grade
#
print ("*********************************************************")
print ("** Welcome to the Grade Calculator                     **")
print ("**                                                     **")
print ("** You will need the following information to proceed: **")
print ("** - Fall Semester (S1) Grade                          **")
print ("** - 3rd Quarter (Q3) Grade                            **")
print ("**                                                     **")
print ("*********************************************************")
print("")
minC = 68.5
#Minimum average grade for "C" per Ferris ISD
minB = 79.5
#Minimum average grade for "B" per Ferris ISD 
minA = 89.5
#Minimum average grade for "A" per Ferris ISD
s1 = float(input("What is your Fall Semester (S1) Grade? "))
#Ask for S1 input and cast as float
q3 = float(input("What is your 3rd Quarter (Q3) Grade? "))
#Ask for Q3 input and cast as float
semMinC = str ( round ( ( ( ( 5 * minC ) - ( q3 * 2 ) ) / 3 ), 2) )
#C Algorithm - Developed on 19-March-2018 rounded to 2 decimal places and cast as a string
semMinB = str ( round ( ( ( ( 5 * minB ) - ( q3 * 2 ) ) / 3 ), 2) )
#B Algorithm - Developed on 19-March-2018 rounded to 2 decimal places and cast as a string
semMinA = str ( round ( ( ( ( 5 * minA ) - ( q3 * 2 ) ) / 3 ), 2) )
#A Algorithm - Developed on 19-March-2018 rounded to 2 decimal places and cast as a string
print("")
print("***********Q4 & SE2 MINIMUMS (SEMESTER)***********")
print("Min for C for Semester = " + semMinC)
#Outputs minimum for "C" for semester
print("Min for B for Semester = " + semMinB)
#Outputs minimum for "B" for semester
print("Min for A for Semester = " + semMinA)
#Outputs minimum for "A" for semester

You can see that lines 24 through 29 are compressed versions of lines 24 through 41 of the original code. Let’s take a quick look at how this was accomplished:

semMinC = str ( round ( ( ( ( 5 * minC ) - ( q3 * 2 ) ) / 3 ), 2) )

Here is line 24 of the compressed version. You can see that we have a math problem in the middle that is rounded to 2 decimal points that is cast as a string.

The original (expanded) code took the following lines to accomplish the same thing:

semMinC = ( ( ( 5 * minC ) - ( q3 * 2 ) ) / 3 )
semMinCRounded = round(semMinC,2)
semMinCString = str(semMinCRounded)

When we return next class, the students will be developing the second part of the program, which addresses the minimums needed for the 3 cases for the year.

For reference, here is a link to the IDE of the code at this checkpoint:

Grade Calculator Algorithm Development

My Computer Science 1 classes have spent the past two class periods developing two different algorithms for a “minimum grade calculator” assignment.

Our grades are broken up as follows:

  • Semester 1 (S1) – 50% of Year
    • Quarter 1 (Q1) – 45% of Semester 1
    • Quarter 2 (Q2) – 45% of Semester 1
    • Semester Exam 1 (SE1) – 10% of Semester 1
  • Semester 2 (S2) – 50% of Year
    • Quarter 3 (Q3) – 45% of Semester 2
    • Quarter 4 (Q4) – 45% of Semester 2
    • Semester Exam 2 (SE2) – 10% of Semester 2

The assignment was to develop a program that would let students know the minimum needed grade(s) for the remaining grading periods to pass for both the semester and for the year. As part of this project, the only remaining grades are Q4 and SE2. This is 55% of the semester and 27.5% of the year.

We started by spending two days in algorithm development. The play had been for one day, but you’ll see why it took us two days.

Algorithm – Minimum for Semester

We started with development of a minimum grade for the semester. So, we started with this:

s2 = ( ( q3 * 2 ) + ( q4 * 2 ) + se2 ) / 5

We then condensed it to the following:

s2 = ( ( q3 * 2 ) + ( MIN * 3 ) ) / 5

The “MIN” is the minimum grade that is needed for the 3/5 of the average that is still outstanding. We then moved to isolate the “MIN” variable as follows:

s2 = ( ( q3 * 2 ) + ( MIN * 3 ) ) / 5
( 5 * s2 ) = ( q3 * 2 ) + ( MIN * 3 )
( 5 * s2 ) - ( q3 * 2 ) = MIN * 3
( ( 5 * s2 ) - ( q3 * 2 ) ) / 3 = MIN

We verified the algorithm against an established dataset and it checked.

Algorithm – Minimum for Year (Take 1)

The minimum for the year algorithm was the one that gave us a problem. We got it developed by the end of the first day, but it failed testing. You’ll see why, but we didn’t get a chance to correct it until the next class.

We started with the following:

y = ( s1 + s2 ) / 2

We then expanded it to the following:

y = ( s1 + ( ( ( q3 * 2 ) + ( q4 * 2 ) + se2 ) / 5 ) ) / 2

Like earlier, we consolidated the 6/10 of the year average (3/5 of the semester 2 average) as follows:

y = ( s1 + ( ( ( q3 * 2 ) + ( MIN * 3 ) ) / 5 ) ) / 2

The “MIN” is the minimum grade that is needed for the 3/5 of the semester average that is still outstanding. We then moved to isolate the “MIN” variable as follows: (NOTE: This is where our error occurred).

y = ( s1 + ( ( ( q3 * 2 ) + ( MIN * 3 ) ) / 5 ) ) / 2
2 * y = s1 + ( ( ( q3 * 2 ) + ( MIN * 3 ) ) / 5 )
( 10 * y ) = s1 + ( q3 * 2 ) + ( MIN * 3 )
( 10 * y ) - s1  = ( q3 * 2 ) + ( MIN * 3 )
( 10 * y ) - s1  - ( q3 * 2 ) = ( MIN * 3 ) 
( ( 10 * y ) - s1  - ( q3 * 2 ) ) / 3 = MIN

When we verified this against the dataset, it failed the tests. Regretfully, we ran out of time to correct it, so we had to push the correction to the next class period.

Algorithm – Minimum for Year (Take 2)

We verified the original algorithm once again and determined that it was wrong and would result in a logic error if used.

We analyzed the notes:

y = ( s1 + ( ( ( q3 * 2 ) + ( MIN * 3 ) ) / 5 ) ) / 2
( 2 * y ) = s1 + ( ( ( q3 * 2 ) + ( MIN * 3 ) ) / 5 )
( 10 * y ) = s1 + ( q3 * 2 ) + ( MIN * 3 )
( 10 * y ) - s1  = ( q3 * 2 ) + ( MIN * 3 )
( 10 * y ) - s1  - ( q3 * 2 ) = ( MIN * 3 ) 
( ( 10 * y ) - s1  - ( q3 * 2 ) ) / 3 = MIN

We discovered that the error occurred at line 3. So, we adjusted the algorithm as follows:

y = ( s1 + ( ( ( q3 * 2 ) + ( MIN * 3 ) ) / 5 ) ) / 2
( 2 * y ) = s1 + ( ( ( q3 * 2 ) + ( MIN * 3 ) ) / 5 )
( ( 2 * y ) - s1 ) = ( ( q3 * 2 ) + ( MIN * 3 ) ) / 5
( 5 * ( ( 2 * y ) - s1 ) ) = ( q3 * 2 ) + ( MIN * 3 )
( ( 5 * ( ( 2 * y ) - s1 ) ) - ( q3 * 2 ) ) = MIN * 3
( ( 5 * ( ( 2 * y ) - s1 ) ) - ( q3 * 2 ) ) / 3 = MIN

We verified the algorithm against an established dataset and it checked.