# Ryan Martin
# macid: abcd123
# student number: #######
# August 8, 2011
#
# This is a solution for Major Assignment 3 (Lab 08)

def makeCenteredRow(w, c):
    '''Returns a string with c at the center of w and empty elsewhere.'''
    line = ' ' * (w/2) + c
    return line  # (w,c)are the input you will use in the function. In this function, w is an odd interger and c is a sting.
                  # Basically, you will just create an output with half of the w spaces and follow by c( c is the sring you put)
                  # eg.you can put makeCenterdRow(7,"#") , then you will create a new string which have 3 spaces and follow by c, so it will be "   #"

def makeRow(a, b, c):
    '''Returns a string with a spaces, c, b spaces, and c again.'''
    
    line = ' ' * a + c + ' ' * b + c   
    return line
### This function is similar to the previous one, and both a and b are the integers. C will be the string
## Therefore, the function with these numbers will create a spaces follow by c and b spaces follow by c.
## eg. if you have  makeRow(3,6,"#"), you will create "   c      c" . the first blank in front of the c is 3 empty spaces
## the spaces between two c are 6




def makeDiamond(w, c):
    '''Returns a list of lines that form a hollow diamond 
    of width and height w > 2 (odd) made of the character c.'''

    result = []
    result.append(makeCenteredRow(w, c))     # this formula just append the first row in the list. This first row use the makeCenteredRow function.
                                              #  so it will have (w/2)*' '+c as result

    for i in range(0, w/2):
        result.append(makeRow(w/2 - i - 1, 2*i + 1, c))  # These two loops create the  body part (The first loop is for the upper part and the second loop
                                                         #   is for the lower part of the diamond. in order to get the input formula for a and b,
                                                         #    you need to draw the diagram out first, and figure out how many spaces are in front of the first c,
                                                        #    and how many spaces are in between the two c.

                                                        #   you will need to find the formula that can represent both a and b with repect to i and w. 
    for i in range(w/2 - 2, -1, -1):
        result.append(makeRow(w/2 - i - 1, 2*i + 1, c))

    # alternatively
    # for i in range(w/2 - 1):
    #    result.append(makeRow(i+1, w/2 - i*2, c))

    result.append(makeCenteredRow(w, c))

    return result

'''
Design Question

There should be w/2 spaces before c in
makeCenteredRow, so that c is placed in the
exact middle of w. Since w is an odd integer,
the remainder of w/2 will always be 1.
(w - 1)/2 == w/2; integer division in this case
will help determine the number of spaces preceeding
c.

'''
##Note: This format is used by our automated marking system.
##You will see that, for inputs, the function name is
##given with the corresponding inputs to that function
##listed right after it.
##Format: [funName, [arg1, arg2, ...]]

'''
Test Plan

V08 = {'test1':
       {'inputs':['makeCenteredRow',[5, '@']],
        'outputs':['  @']},
        
       'test2':
       {'inputs':['makeRow',[2, 4, '$']],
        'outputs':['  $    $']},
                
       'test3':
       {'inputs':['makeDiamond',[11, '%']],
        'outputs':[['     %', '    % %', '   %   %', '  %     %', ' %       %', '%         %', ' %       %', '  %     %', '   %   %', '    % %', '     %']]},
                
       'test4':
       {'inputs':['makeRow',[0.5, 2, '%']],
        'outputs':[TypeError]},
                
       'test5':
       {'inputs':['makeDiamond',[6, '&']],
        'outputs':[['   &', '  & &', ' &   &', '&     &', ' &   &', '  & &', '   &']]},
                
       'test4':
       {'inputs':['makeDiamond',[1, '\n']],
        'outputs':[['\n', '\n']]},
        
      }



'''
