# Ryan Martin
# macid: abcd123
# student number: #######
# August 8, 2011
#
# This is a solution for Marked Assignment 3 (Lab 07) on Wednesday.

def makeCenteredRow(w, c):
    '''Returns a string with c at the center of w and empty elsewhere.'''
    line = ' ' * (w/2) + c
    return line

def makeRow(a, b, c):
    '''Returns a string with a spaces, c, b spaces, and c again.'''
    
    line = ' ' * a + c + ' ' * b + c
    return line

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))

    for i in range(0, w/2):
        result.append(makeRow(w/2 - i - 1, 2*i + 1, c))
    
    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.

Testing Report

Test: 1 for function makeCenteredRow
Input: [(5, '@')]
Expected Output: ['  @']
Actual Output: ['  @']
Result:pass

Test: 1 for function makeRow
Input: [(2, 4, '$')]
Expected Output: ['  $    $']
Actual Output: ['  $    $']
Result:pass

Test: 1 for function makeDiamond
Input: [(11, '%')]
Expected Output: [['     %', '    % %', '   %   %', '  %     %', ' %       %', '%         %', ' %       %', '  %     %', '   %   %', '    % %', '     %']]
Actual Output: [['     %', '    % %', '   %   %', '  %     %', ' %       %', '%         %', ' %       %', '  %     %', '   %   %', '    % %', '     %']]
Result:pass
'''