Ulam-Warburton Automaton Hex

Ulam-Warburton Automaton Hex

example

This mission is dedicated to hexagonal version the Ulam–Warburton cellular automaton (UWCA) - a 2-dimensional fractal pattern that grows on a regular grid of cells consisting of hexagon's.

Starting with one hexagon initially ON and all others OFF, successive iterations are generated by turning ON all hexagons that share precisely one edge with an ON hexagon.

This pattern is shown among others (so I recommend you to watch it all) in the following video with Neil Sloane (founder of the On-Line Encyclopedia of Integer Sequences) starting from the 11.50.

The playground of this and other patterns may be seen on the page. It will be easier to solve the task and it's just a beautiful hypnotic view!)

So, your function must return the number of activated cells after given number of steps.

Input: Number of steps as Number.

Output: Number of cells as Number.

Examples:

assert.strictEqual(automaton(1), 1);
assert.strictEqual(automaton(2), 7);
assert.strictEqual(automaton(3), 13);
assert.strictEqual(automaton(4), 31);