# Authors:
# Date: 10/31/25
# Practicum 3, Part 2 (2 of 20 points)
""" This file contains the instructions and  skeleton code for Part 1 of Prac 3.
In this program, you will write a function to plot a bar chart for a grade
distribution. The plot_dist function takes 5 non-negative integers as input,
representing the number of students earning letter grades A, B, C, D, and F.
The function returns a bar chart, as a string, with one '#' per student in the
format shown in the following examples:

Examples:
>>> print(plot_dist(3, 5, 6, 4, 1))
    #     
  # #     
  # # #   
# # # #   
# # # #   
# # # # # 
a b c d f
>>> print(plot_dist(0, 1, 0, 0, 0))
  #       
a b c d f
>>> print(plot_dist(1, 2, 3, 5, 0))
      #   
      #   
    # #   
  # # #   
# # # #   
a b c d f
>>> 

There is no main program required; you only need to implement the
function below. If you do write a main program for testing purposes, put the
main program code inside a main guard.
"""

def find_max(lst):
    """ Find and return the maximum value in lst.
    Preconditions: lst is a list of integers >= 0 """
    mx = 0
    for v in lst:
        if v > mx:
            mx = v
    return mx

def plot_dist(a, b, c, d, f):
    """ Return a bar chart with 5 columns, one for each letter grade.
    The chart is labeled with 'a b c d f' on the bottom line, and each column
    has a stack of '#'s representing the number of students with that grade."""
    
    largest = find_max([a, b, c, d, f])
    
    result = ""
    
    for row in range(largest, 0, -1):
        for grade in [a, b, c, d, f]:
            if grade >= row:
                result += "# "
            else:
                result += "  "

        result += "\n"

    result += "a b c d f\n"
    return result
    
    
def plot_dist(a, b, c, d, f):
    """ Return a bar chart with 5 columns, one for each letter grade.
    The chart is labeled with 'a b c d f' on the bottom line, and each column
    has a stack of '#'s representing the number of students with that grade."""
    
    foot = "a b c d f"
    largest = find_max([a, b, c, d, f])
    
    for row in range(1, largest + 1):
    
    result = ""
    
    for row in range(largest, 0, -1):
        for grade in [a, b, c, d, f]:
            if grade >= row:
                result += "# "
            else:
                result += "  "

        result += "\n"

    result += "a b c d f\n"
    return result
    