Skip to content

Instantly share code, notes, and snippets.

@muse
Last active August 29, 2015 14:16
Show Gist options
  • Save muse/ccadac87941aa82bbe38 to your computer and use it in GitHub Desktop.
Save muse/ccadac87941aa82bbe38 to your computer and use it in GitHub Desktop.
Make a triangle in only one line. Magic they call it.
#!/usr/bin/env python
# Made by 'Mirko van der Waal'
# Distributed under terms of the MIT license.
triangle = lambda n:'\n'.join(['\n'.join([' '*(2*n-2*i-2)+"*"+' '*(4*i-5)+"*"*(i!=1) for i in range(1,n-1)]),'* '*(2*n-3)])
# Call as triangle(int).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment