Last active
August 29, 2015 14:16
-
-
Save muse/ccadac87941aa82bbe38 to your computer and use it in GitHub Desktop.
Make a triangle in only one line. Magic they call it.
This file contains 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
#!/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