Skip to content

Instantly share code, notes, and snippets.

@Cycymomo
Last active December 19, 2015 21:39
Show Gist options
  • Save Cycymomo/6021875 to your computer and use it in GitHub Desktop.
Save Cycymomo/6021875 to your computer and use it in GitHub Desktop.
// 140bytes - http://www.developpez.net/forums/d1362763/webmasters-developpement-web/javascript/ludique-defis-code-en-tweet/
(function cercle(r){
a='';for(i=~r;i++<r;a+='\n')for(j=-r*2;j++<r*2;)a+=j*j/4<r*r-i*i?'#':' ';return a
})(20);
/* draw this : */
"
#########################
###################################
###########################################
###############################################
#####################################################
#########################################################
#############################################################
###############################################################
###################################################################
#####################################################################
#######################################################################
#########################################################################
###########################################################################
#############################################################################
#############################################################################
###############################################################################
###############################################################################
###############################################################################
###############################################################################
###############################################################################
###############################################################################
###############################################################################
###############################################################################
###############################################################################
#############################################################################
#############################################################################
###########################################################################
#########################################################################
#######################################################################
#####################################################################
###################################################################
###############################################################
#############################################################
#########################################################
#####################################################
###############################################
###########################################
###################################
#########################
"
@JavaScript-Packer
Copy link

I used your function to make circle shape for happy face for http://www.whak.ca/packer/smilies.htm, thanks!

document.write('<pre>'+(function(r){a='';for(i=~r;i++<r;a+='\n')for(j=-r*2;j++<r*2;)a+=j*j/4<r*r-i*i?'#':' ';return a})(20)+'</pre>')

//133 bytes

@JavaScript-Packer
Copy link

11 bytes off yours:

!function(r){for(a="",i=~r;i++<r;a+="\n")for(j=2*-r;j++<2*r;)a+=r*r-i*i>j*j/4?"#":" ";return a}(20)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment