<commit_before># U1.W3: Calculate a letter grade!

# Complete each step below according to the challenge directions and 
# include it in this file. Also make sure everything that isn't code
# is commented in the file.  

# I worked on this challenge [by myself, with: ].

# 1. Pseudocode

# What is the input?
# What is the output? (i.e. What should the code return?)
# What are the steps needed to solve the problem?


# 2. Initial Solution




# 3. Refactored Solution



# 4. Reflection <commit_msg>Updated my solution.<commit_after># U1.W3: Calculate a letter grade!

# Complete each step below according to the challenge directions and 
# include it in this file. Also make sure everything that isn't code
# is commented in the file.  

# I worked on this challenge by myself.

# 1. Pseudocode

# What is the input?
# The input is an array of grades. I need to calculate the average. 
# What is the output? (i.e. What should the code return?)
# The code should return the letter grade that represents the calcuated average grade.
# What are the steps needed to solve the problem?
# First, need to calculate the average of the grades in the array.
# Then, use some if statements to find what grade it is.
# Then, return it. 


# 2. Initial Solution
get_grades(array)
{
  i = 0
  sum = 0
  avg = 0
  
  while i < array.length do
  {
    sum = sum + array[i]
    i = i + 1
  } end
  
  avg = sum/array.length
  
  if avg >= 90
    return "A"
  end
  
  if avg >= 80
    return "B"
  end
  
  if avg >= 70
    return "C"
  end

  if avg >= 60
    return "D"
  end
  
  else
  return "F"
  end
end
}



# 3. Refactored Solution
get_grades(array)
{
  i = 0
  sum = 0
  avg = 0
  
  if array == NULL
    return NULL
  end
  
  while i < array.length do
  {
    sum = sum + array[i]
    i = i + 1
  } end
  
  avg = sum/array.length
  
  if avg >= 90
    return "A"
  end
  
  if (avg >= 80 && avg < 90)
    return "B"
  end
  
  if (avg >= 70 && avg < 80)
    return "C"
  end

  if (avg >= 60 && avg < 70)
    return "D"
  end
  
  else
  return "F"
  end
end
}

# I just wanted to ensure that it went through the if statements correctly to return the grade. I also wanted to 
# account for the array equaling NULL. 


# 4. Reflection 
This assignment was fun because it was like a step higher than the socrates practice that we did earlier. We had to
combine two skills really in this one, finding the average and using if statements. I had a clear plan with this
project and that was evident by the pseudo code that I wrote. Every time that you do more practicing, things always
seem to get easier. I am ready to keep moving forward. 
{'fraction_non_alphanumeric': 0.07248576850094876, 'fraction_numerical': 0.015939278937381403, 'mean_word_length': 2.610958904109589, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '116368', 'n_tokens_mistral': 901, 'n_tokens_neox': 834, 'n_words': 413}