92
votes
Unfolding the Hexagony source code
Hexagony, 271 bytes
I present to you, the first 3% of a Hexagony self-interpreter...
...
57
votes
Triangular Lattice Points close to the Origin
Python 2, 43 bytes
f=lambda n,a=1:n*n<a/3or n*n/a*6-f(n,a+a%3)
Try it online!
This is black magic.
Offering 250 rep for a written-up proof. See Lynn's ...
46
votes
41
votes
Could you make me a hexagon please?
Hexagony + Bash Coreutils, 0+3+8 = 11 Bytes
Includes +3 for -g flag and +8 for |tr . \* non-standard invocation (see this meta ...
38
votes
34
votes
Triangular Lattice Points close to the Origin
Haskell, 48 bytes
f n=1+6*sum[(mod(i+1)3-1)*div(n^2)i|i<-[1..n^2]]
Try it online!
Uses xnor's "black magic" formula:
$$f(n)=1+6\sum_{a=0}^\infty \...
32
votes
Accepted
30
votes
Triangular Lattice Points close to the Origin
Wolfram Language (Mathematica), 53 51 50 bytes
-1 byte thanks to @miles
Sum[Boole[x(x+y)+y^2<=#^2],{x,-2#,2#},{y,-2#,2#}]&
Try it online!
How?
Instead of ...
24
votes
23
votes
Accepted
A spiral sequence
JavaScript (ES6), 267 .. 206 199 bytes
Returns an array containing the \$N\$ first terms of the sequence.
...
20
votes
Could you make me a hexagon please?
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 ...
20
votes
19
votes
Accepted
19
votes
HexaGolf: Wordagons
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 ...
19
votes
18
votes
Unfolding the Hexagony source code
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 ...
18
votes
HexaRegex: A Tribute to Martin Ender
Retina, 744 bytes
Sorry folks, no Hexagony this time...
Byte count assumes ISO 8859-1 encoding.
...
16
votes
Accepted
Cut a triangle into equal-sized parts!
JavaScript (ES7), 367 362 359 357 bytes
Saved 1 byte thanks to @Shaggy
Expects (n)(m).
...
15
votes
15
votes
Could you make me a hexagon please?
Hexagony, 91 87 86 bytes
?{2'*=&~}=&}='P0</0P}|@..;>;'.\};0Q/..\&(<>"-_"&}=\?_&\/8.=-\<><;{M/.(.(/.-{><.{&'/_.\
...
14
votes
HexaGolf: Rotatagons
Python 2, 160 158 156 148 124 bytes
Prepare to be amazed! The resulting text is drawn on a canvas... by a Turtle! :D
...
13
votes
Accepted
Unfolding the Hexagony source code
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 >...
13
votes
Accepted
Triangular Ulam spiral
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 ...
13
votes
HexaRegex: A Tribute to Martin Ender
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: ...
13
votes
Could you make me a hexagon please?
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?
...
13
votes
12
votes
Motion on a hexagonal grid
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
...
12
votes
Could you make me a hexagon please?
JavaScript (ES6), 77 76 bytes
g=(n,s=`
*`+' *'.repeat(n*2-2),c=s,q=c.replace('*',''))=>--n?g(n,q+s+q,q):s
I told myself I wouldn't sleep until I had set a new ...
12
votes
11
votes
Accepted
Hexplosive ASCII-art challenge
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 <...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
hexagonal-grid × 67code-golf × 62
ascii-art × 23
board-game × 7
kolmogorov-complexity × 6
geometry × 6
math × 5
sequence × 5
tiling × 5
decision-problem × 4
grid × 4
combinatorics × 3
path-finding × 3
puzzle-solver × 3
complex-numbers × 3
string × 2
number × 2
graphical-output × 2
primes × 2
game × 2
graph-theory × 2
fastest-code × 2
king-of-the-hill × 2
cellular-automata × 2
java × 2