Skip to content

Instantly share code, notes, and snippets.

@neizod
Forked from Python1Liners/LICENSE.txt
Last active December 14, 2015 04:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neizod/5030037 to your computer and use it in GitHub Desktop.
Save neizod/5030037 to your computer and use it in GitHub Desktop.
Happy Valentine's Day
(lambda r: '\n'.join(''.join('x' if (y < r and ((x-r)**2 + (y-r)**2 <= r**2 or (x-3*r)**2 + (y-r)**2 <= r**2)) or (y >= r and x + r >= y and x - r <= 4*r - y) else ' ' for x in range(4*r)) for y in range(1, 3*r, 2)))(14)

Happy Valentine's Day

Draw heart on 56x21 chars box. Inspiration by Dittaya's post.

Output

         @@@@@@@@@@@                 @@@@@@@@@@@        
      @@@@@@@@@@@@@@@@@           @@@@@@@@@@@@@@@@@     
    @@@@@@@@@@@@@@@@@@@@@       @@@@@@@@@@@@@@@@@@@@@   
  @@@@@@@@@@@@@@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@@@@@@ 
 @@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@
 @@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@
 @@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@
 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  
     @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@    
       @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@      
         @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@        
           @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@          
             @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@            
               @@@@@@@@@@@@@@@@@@@@@@@@@@@              
                 @@@@@@@@@@@@@@@@@@@@@@@                
                   @@@@@@@@@@@@@@@@@@@                  
                     @@@@@@@@@@@@@@@                    
                       @@@@@@@@@@@                      
                         @@@@@@@                        
                           @@@                          
(lambda r:
'\n'.join(
''.join(
'@'
if (y < r
and ((x-r)**2 + (y-r)**2 <= r**2
or (x-3*r)**2 + (y-r)**2 <= r**2))
or (y >= r
and x + r >= y
and x - r <= 4*r - y)
else
' '
for x in range(4*r))
for y in range(1, 3*r, 2)))(14)
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2013 Nattawut Phetmak <http://about.me/neizod>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
{
"name": "happy_valentines_day",
"description": "draw heart on 56x21 chars box.",
"keywords": [
"ascii art",
"letter"
]
}
print((lambda r: '\n'.join(''.join('x' if (y < r and ((x-r)**2 + (y-r)**2 <= r**2 or (x-3*r)**2 + (y-r)**2 <= r**2)) or (y >= r and x + r >= y and x - r <= 4*r - y) else ' ' for x in range(4*r)) for y in range(1, 3*r, 2)))(14))
# result:
# @@@@@@@@@@@ @@@@@@@@@@@
# @@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@
# @@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@
# @@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@
# @@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@
# @@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@
# @@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# @@@@@@@@@@@@@@@@@@@@@@@@@@@
# @@@@@@@@@@@@@@@@@@@@@@@
# @@@@@@@@@@@@@@@@@@@
# @@@@@@@@@@@@@@@
# @@@@@@@@@@@
# @@@@@@@
# @@@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment