12
Challenge
Winter is fast approaching with many places receiving the first layers of snow for the 15/16 season, so why don't we break out the snow machines and code ourselves some snow?
Given a integer n
via STDIN, output an ASCII representation Beta's snowflake (as described below) at level n
.
Beta's Snowflake
The snowflake starts off at level 0 with a single x:
x
Then, on each corner you add one of these shapes:
x
xx
You add the above shape to a top right corner. For a bottom right corner, rotate it 90° clockwise, for bottom left, 180° clockwise and for top left, 270° clockwise.
If you do that, you get the following shape:
x x
xx xx
x
xx xx
x x
Take note of the orientation of the shapes. Carrying on we add more of the shapes to each corner, using the orientation rules described above, to the diagram to get level 2:
x x x
xxxxxxx
xx x x xx
xxx xxx
xx x xx
xxx xxx
xx x x xx
xxxxxxx
x x x
Note that the shapes are only added to x
s with two or more exposed sides (which is referred to as a corner above).
The L-shapes may and will overlap for values of n
greater than 1. For example:
If level 0 is:
x x
Then there must be overlaps in level 1 (indicated with an o
, do not include the o
in your output):
x o x
xxxoxxx
x x
xxxoxxx
x o x
Your task is to output this ASCII representation of Beta's snowflake.
Bonus
There will be a 50 rep bonus for the shortest program which, when n
is negative, outputs the snowflake (at level n*-1
) as an image or graphically to the screen.
You may have a separate programs for the bounty and the main task.
Winning
The shortest program in bytes wins.
4A gamma snowflake is a 3d version of this. – Conor O'Brien – 2015-10-26T18:06:56.113
1@CᴏɴᴏʀO'Bʀɪᴇɴ Well that's an idea for a follow up challenge ;) – Beta Decay – 2015-10-26T18:08:13.140
Can you clarify the
2 or more exposed sides
rule? Assuming center is0,0
then1,1
,1,-1
,-1,-1
,-1,1
all have 2 exposed sides (the sides facing towards the other 4 points). Shouldn't it be 3+ open sides to avoid infilling? Or alternately it only expands if it has 0 or 1 neighbors (cardinal). – Jonathan Leech-Pepin – 2015-11-05T14:55:42.650As per above, it would also lead to additional growth in cases like n=2 on the corners of the 'square' around the center (it is not a peak, but it is exposed on the W,NW,N sides (for top left). – Jonathan Leech-Pepin – 2015-11-05T14:58:51.127