Skip to main content

Timeline for Draw an hourglass

Current License: CC BY-SA 3.0

11 events
when toggle format what by license comment
Jun 17, 2020 at 9:04 history edited CommunityBot
Commonmark migration
Oct 28, 2016 at 9:39 comment added Kevin Cruijssen @Numberknot Umm.. you still forgot my second tip. Anyway, here is a shorter variant: String c(int n,int x){String s,c=s="";int i=0;for(;i++<n;s+="*");for(i=x;i-->0;c+=" ");return n>1?s+"\n "+c+c(n-2,x+1)+"\n"+c+s:"*";} without the t (ideone test - 133 bytes)
Oct 26, 2016 at 11:45 history edited Numberknot CC BY-SA 3.0
deleted 1 character in body
Oct 26, 2016 at 11:31 comment added Kevin Cruijssen @Numberknot I know, but I also changed n to n-2 at that part. return(n=n-2)>=0 ... n being changed to return n-1>0 ... n-2 is still shorter. PS: You've thanked me for saving bytes, but haven't changed your code in your edit. ;)
Oct 26, 2016 at 10:17 history edited Numberknot CC BY-SA 3.0
added 46 characters in body
Oct 26, 2016 at 10:15 comment added Numberknot But @KevinCruijssen pattern not as expected after changing n=n-2->n-1>0 because n should be used in other argument of a function.
Oct 26, 2016 at 9:40 comment added Kevin Cruijssen Hi. You can golf two parts: String s="",c="",t=""; to String s,c,t=s=c=""; (-2 bytes), and return(n=n-2)>=0?s+"\n"+c+c(n,++x)+ to return n-1>0?s+"\n"+c+c(n-2,++x)+ (-2 bytes again)
Oct 26, 2016 at 8:20 history edited Numberknot CC BY-SA 3.0
added 52 characters in body
Oct 25, 2016 at 23:04 comment added Hypino You can save 2 bytes by removing s= from s=s+"\n"and 2 more bytes by changing return(n=--n-1) to return(n=n-2) for a total of 4 bytes.
Oct 25, 2016 at 20:42 review Low quality posts
Oct 25, 2016 at 20:45
Oct 25, 2016 at 20:25 history answered Numberknot CC BY-SA 3.0