90

Hexagony, 271 bytes I present to you, the first 3% of a Hexagony self-interpreter... |./...\..._..>}{<$}=<;>'<..../;<_'\{*46\..8._~;/;{{;<..|M..'{.>{{=.<.).|.."~....._.>(=</.\=\'$/}{<}.\../>../..._>../_....@/{$|....>...</..~\.>,<$/'";{}({/>-'(<\=&\><${~-"~<$)<....'.>=&'*){=&...


46

Snowman 1.0.2, 157 bytes (()("789:045600230001"4aG::48nSdU][:#:]eq]/nM;AsI[:"_____"wR[" "wR/aC;:"( : )"wR["(.,.)"wR/aC;bI;:" "wRdUaC;bI\#**\;aMaZ:" "aJ1AfL;aM;aM1AfL" "aJ1AfL*)) Try it online! When I saw this challenge, I knew I just had to answer in the perfect language... This is a subroutine that takes input as an array of numbers and outputs as ...


37

Hexagony + Bash Coreutils, 0+3+8 = 11 Bytes Includes +3 for -g flag and +8 for |tr . \* non-standard invocation (see this meta post) Input is given as an argument to Hexagony. When the Hexagony interpreter is called with the -g N option it prints a hexagon of .s. We then use tr to replace those with *s.


33

CJam, 45 43 42 41 40 bytes 741e8 36+Ab"\__/ "38*21/.{G2$-<\S*.e<N} Try it online in the CJam interpreter. How it works "\__/ "38*21/ repeats the pattern \__/ 38 times and splits it into chunks of length 21. If the chunks were separated by linefeeds, this would be the result: \__/ \__/ \__/ \__ / \__/ \__/ \__/ \__/ \__/ \__/ \__ / \...


32

Python 2, 64,515 import sys input = map(str.rstrip, sys.stdin.readlines()) width = (len(input[-1]) + 1) / 2 for i in range(len(input)): indent = len(input) - i - 1 input[i] = [c != " " for c in input[i][indent::2]] input[i] += [False] * (width - indent - len(input[i])) input = [[False] * n for n in range(width - len(input) + 1)] + input ...


31

Hexagony, 2437 bytes The long-awaited program is here: (.=$>({{{({}}{\>6'%={}{?4=$/./\_><./,{}}{<$<\?{&P'_("'"#<".>........_..\></</(\.|/<>}{0/'$.}_.....><>)<.$)).><$./$\))'"<$_.)><.>%'2{/_.>(/)|_>}{{}./..>#/|}.'/$|\})'%.<>{=\$_.\<$))<>(|\4?<.{.%.|/</{=......


28

Python 2, 73 i=0 exec"k=max(7-i,i-24,0);print' '*k+('\__/ '*9)[i:][k:16-k];i+=3;"*11 See it run. For each of the 11 output rows, computes the number of leading spaces k as a maximum of three linear functions that form the envelope of the left side of the hexagon. Because the diagonal lines have slope 3 and -3, it's better to index the row number as i=0,3,...


23

JavaScript (ES6),  267 .. 206  199 bytes Returns an array containing the \$N\$ first terms of the sequence. n=>(F=v=>++i<n?F([...v,(A=N[i]=[1,!j++||d+1,j%L?d:(j%=L*6)?++d:L++&&d++].map(k=>N[k=i-k].push(i)&&k),g=k=>v[E='every']((V,x)=>V-k|N[x][E](y=>A[E](z=>v[y]-v[z])))?k:g(-~k))()]):v)([L=1],N=[[i=j=d=0]]) ...


22

CJam, 65 56 55 bytes "Ý6TNð*¯5"303b4b["/\_")"_ "4*S]f=sB/z{_W%"\/"_W%erN}/ Try it online in the CJam interpreter. Idea The right half of each line is a reversed copy of the left half with slashes and backslashes swapped. Therefore, it suffices to encode the left half of the honeycomb: _ __/ __/ \_ / \__/ \__/ \_ / \__/ \__/ \_ / \__/...


20

Python 2, 61 bytes i=n=input() while~-n+i:i-=1;j=abs(i);print' '*j+'* '*(2*n+~j) Prints a trailing space at the end of each line. Thanks to Erik the Outgolfer for saving a byte.


20

JavaScript (Node.js),  578 ... 433  431 bytes f=(n,T=[B=[N=0,0,0,1,1]])=>!n||T.some(([x,y,q,m])=>B.some((p,d)=>m>>d&1&&((p=x+~-s[d],q=y+~-s[d+2],t=T.find(([X,Y])=>X==p&Y==q))?(q=t[3])&(p=D[d*3+t[4]])^p?t[f(n,T,t[3]|=p),3]=q:0:[0,1,2].map(t=>f(n-1,[...T,[p,q,-p-q,D[d*3+t],t]])))),s="2100122",D=Buffer("160).(...


19

CJam, 56 52 50 48 bytes My first thought was, "hey I already have code for this!" But then I couldn't be bothered to pull the necessary pieces together from the Ruby code, especially because they didn't seem very suitable to being golfed. So I tried something else in CJam instead... lS-{_,4*(3/mq:D1%}{'.+}wD{D(2/-z_S*D@-@/(S*N@s}/ Test it here. ...


19

Python 2, 83 bytes s=input() l=len(s) while 1:l-=1;y=abs(l);print' '*y+' '.join(s[:y:-1]+s[y]*y+s[y:]) Prints the wordagon and then crashes (which only prints to STDERR). Example: % python2.7 wordagon.py <<<'"abcde"' 2&>/dev/null e e e e e e d d d d e e d c c c d e e d c b b c d e e d c b a b c d e e d c b b c d e e d c c c d ...


17

brainfuck - 617 616 604 bytes +>>>>,[>++++[<-------->-]<[>>>>],]<<<<[>+<<+<+>>-]<[>+<-]+<+<<[>+>-<<-]>[<+>-]>[,+++++[>+++++<-]>>[<->-]<[>>>>>[>>>>]+[<<<<]<-]>>[<+>-]<<<...


17

Python 2, 291 bytes def f(M): Y=map(max,M).index("S");X=M[Y].find("S");V={()};Q=[(0,0,0,1,"")] while Q: try:x,y,u,v,p=s=Q.pop(0);c=(Y>=y<=X-2*x)*ord(M[Y-y][X-2*x-y]) except:c=0 if c==69:return p if{c%2*s[:4]}-V:V|={s[:4]};Q+=(x+u,y+v,u,v,p+"F"),(x,y,-v,u+v,p+"R"),(x,y,u+v,-u,p+"L") return"Invalid maze!" A function, f, taking the ...


16

CJam, 61 59 43 40 38 36 bytes {{_N/eeSf.*:sW%zsS-\{_' >{;(}&+}/}*} This is an anonymous function that expects a string and an integer on the stack. Thanks to @jimmy23013 for golfing off 19 bytes. Try it online in the CJam interpreter. Idea We can assign an order to the printable characters of the checkerboards by reading them eastwards, then ...


15

JavaScript (ES6), 118 117 bytes n=>[...Array(m=n+--n)].map((_,i,a)=>a.map((_,j)=>(k=j-(i>n?i-n:n-i))<0?``:k&&++j<m?i/2%n?6:4:3+!i%n).join` `).join`\n` Where \n represents a literal newline character. Explanation: Suppose n=4. We start with the following space-separated digit square: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...


14

Python 2, 108 bytes def f(x): for i in 4,3,2,1:print" "*(4-i)+" ".join(".O"[i*~-i/2-~z in map(int,x.split())]for z in range(i)) Call with f("3 5 7 9 10"). i is the row number, with 4 being the first row and 1 being the last. z is the nth pin on that row, with 0 meaning it's the first pin in the row and i-1 meaning it's the last pin in the row. The main ...


14

Retina, 744 bytes Sorry folks, no Hexagony this time... Byte count assumes ISO 8859-1 encoding. .+¶ $.'$*_¶$& ^_¶ ¶ ((^_|\2_)*)_\1{5}_+ $2_ ^_* $.&$*×_$&$&$.&$*× M!&m`(?<=(?=×*(_)+)\A.*)(?<-1>.)+(?(1)!)|^.*$ O$`(_)|.(?=.*$) $1 G-2` T`d`À-É m`\A(\D*)(?(_)\D*¶.|(.)\D*¶\2)((.)(?<=(?<4>_)\D+)?((?<=(?<1>\1.)\4\...


14

Python 2, 160 158 156 148 124 bytes Prepare to be amazed! The resulting text is drawn on a canvas... by a Turtle! :D from turtle import* h,n=input() up() rt(n*60) l=0 for c in h: write(c);fd(9);l-=1 if" ">c:fd(9*l);rt(90);fd(15);lt(90);l=0 Try it online - Supports decimal rotations as well! If you would prefer the turtle to be shaped like one, you ...


13

CJam, 64 57 55 bytes " __ / \ \__/"N/{_SS/\+_47>S3*f{\+}_2>\@?}q~(*]:..e>N* Test it here. This will generate the following pattern, column-wise: __ __ __ __ __ __ / \__/ \__/ \__/ \__/ \__/ \ \__/ \__/ \__/ \__/ \__/ \__/ / \__/ \__/ \__/ \__/ \__/ \ \__/ \__/ \__/ \__/ \__/ \__/ / \__/ \__/ \__/ \__/ \...


13

Pyth, 57 54 50 49 48 46 V+UJfgh*6sUTlK-zd1_UtJ+*d-JNjd:.[K\.^TJZ=+Z+JN Test Suite Prints a leading space on each line. This version requires a proof that 10^n >= 3n(n - 1) + 1 for all n >= 1. Thanks to ANerdI and ErickWong for providing proofs. Following these inequalities: 10^n > (1+3)^n = 1 + 3n + 9n(n - 1) + ... > 3n(n - 1) + 1 one can easily see ...


13

CJam, 49 42 bytes Lri{)mp0S?}%{1$,)/(a@Wf%z+\L*}h;eeSff*W%N* Input as a single integer in STDIN. Output as an ASCII grid with 0 for primes. The rotation of the spiral is not consistent: the largest number of the spiral will always be on the bottom row. Test it here. Explanation The basic idea is to represent the triangle as a ragged 2D array while doing ...


13

Python 3, 990 943 770 709 bytes First answer, yay! EDIT: Golfed adjacency list making. I now use a slightly different formula EDIT 2: Removed unnecessary fluff, golfed a lot more. EDIT 3: Shortened the code for conversion from index in list to coordinates, golfed a few more things. The majority of the bytes relates to making the adjacency list (it has ...


13

JavaScript (ES6), 77 81 84 @Upvoters: don't miss the answer by @ETHproductions, that is 76 bytes Edit Revised after change in spec, trailing space allowed Just for the hat ... hey! No hat? f=(n,b='* '.repeat(n+n-1),o=b)=>--n?f(n,b=` ${b}`.slice(0,-2),b+` ${o} `+b):o Test f=(n,b='* '.repeat(n+n-1),o=b)=>--n?f(n,b=` ${b}`.slice(0,-2),b+` ${o} ...


12

Retina, 353 339 178 175 150 130 129 117 bytes R 5$*r T`aq\we\ds`so`r.+ )`r(.*) $1 ^ : a sq e wd +`(.+)q w$1 +`(.+)d s$1 +`sw (.*)(\1w?): $0$2 +`sw|ws w+ -$0 \w 1 Output is in unary, separated by a colon. That means you won't really see zeroes in the output (although the presence of a colon will tell you which of the two coordinates is zero, if there is ...


11

Python 2, 171 bytes def f(S,n): o="";E=enumerate;B=S.splitlines(1) for r,l in E(B): for c,q in E(l):z=r-8;y=6-(z+c)/2;x=-y-z;exec"x,y,z=-y,-z,-x;"*n;o+=q*(q<"!")or B[z+8][12-y+x] print o This is perhaps the only time I've ever found str.splitlines useful — for all other times, .split("\n") is shorter. Use like f(S,10). Explanation For each char ...


11

MATL, 39 37 bytes 4*3-:!G:+o~YRtP*!tPw4LY)vtI5&lZ+47+*c Try it online! Or verify all test cases. Explanation I get to use convolution again! Consider input n = 3. The code first builds a matrix of size 4*n-3×n by adding the column vector [1; 2; ...; 9] to the row vector [1, 2, 3] with broadcast. This means computing a 2D array array of all pairwise ...


11

Hexagony, 91 87 86 bytes ?{2'*=&~}=&}='P0</0P}|@..;>;'.\};0Q/..\&(<>"-_"&}=\?_&\/8.=-\<><;{M/.(.(/.-{><.{&'/_.\ Try it online! Finally did it. Initially (before realizing how expensive loops are) I expect this may be able to fit in side length 5, but now it's hard enough to fit it into side length 6. To ...


11

JavaScript (ES6), 184 bytes Takes the file F as a character and the rank R as an integer in currying syntax (F)(R). Returns an array of strings. F=>R=>[...'100124566542'].map((X,i)=>(X-=3-(x=(s='abcdefghikl').search(F)))-7<(Y=('9641001469'[i]||10)-(A=Math.abs)(x-5)+17-2*R)&X+Y>3&X+16>Y&X+Y<27&&s[X]+(22-Y-A(X-5))/2)....


Only top voted, non community-wiki answers of a minimum length are eligible