Created
September 1, 2013 21:28
-
-
Save Experiment5X/6407430 to your computer and use it in GitHub Desktop.
TechGame programming challenge
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
def PrintDiaboloLine(centerLen, totalLen): | |
endLen = (totalLen - centerLen) / 2 | |
print endLen * '.' + (centerLen * '@') + endLen * '.' | |
def PrintDiabolo(width, height, iteration): | |
if (iteration * 2) + 1 >= height: | |
PrintDiaboloLine(2, width) | |
return | |
PrintDiaboloLine(width - iteration * 2, width) | |
PrintDiabolo(width, height, iteration + 1) | |
PrintDiaboloLine(width - iteration * 2, width) | |
width = int(raw_input('Width: ')) | |
if width < 10 or width % 2 != 0: | |
sys.exit('Width must be even and at least 10.') | |
height = int(raw_input('Height: ')) | |
if height < width or height % 2 == 0: | |
sys.exit('Height must be odd and at greater than the width.') | |
PrintDiabolo(width, height, 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment