Skip to content

Instantly share code, notes, and snippets.

@Experiment5X
Created September 1, 2013 21:28
Show Gist options
  • Save Experiment5X/6407430 to your computer and use it in GitHub Desktop.
Save Experiment5X/6407430 to your computer and use it in GitHub Desktop.
TechGame programming challenge
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