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

def makeCenteredRow(w, c):
    '''Returns a string with c at the center of w and empty elsewhere.'''
    line = ' ' * ((w - 1)/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 makeCross(w, c):
    '''Returns a list of lines that form an X shape 
    of width and height w > 2 (odd) made of the character c.'''

    result = []

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

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

    return result

'''
Design Question

By using a conditional statement, we could
implement makeCross in a single loop.
By looping over 0 to w, we can use an if-elif-else
block during each iteration to check if we are
under, at, or over the halfway point, and
change our algorithm accordingly.
This may actually result in makeCross being longer
and more complex, since at present we are using
the same calculations everywhere. 
This problem could be a case where the more 
advanced solution is not necessarily the most
clear or efficient solution.

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 makeCross
Input: [(11, '%')]
Expected Output: [['%         %', ' %       %', '  %     %', '   %   %', '    % %', '     %', '    % %', '   %   %', '  %     %', ' %       %', '%         %']]
Actual Output: [['%         %', ' %       %', '  %     %', '   %   %', '    % %', '     %', '    % %', '   %   %', '  %     %', ' %       %', '%         %']]
Result: pass
'''