This competition is over. Thanks for the interesting non-esolang entries, and congrats to Jakuje for his winning JavaScript submission.
In the great tradition of ASCII Art Challenges on this site, here's another one. Given an input, draw a spiral.
&>----v
||>--v|
|||>v||
|||@|||
||^-<||
|^---<|
^-----<
Simple, yeah? Heh, heh, heh ... Yeah...
(Inspired by the ASCII Dragons Curve post, and Optimizer's ASCII Art of the Day posts)
Input
Input will be in the form of a series of parameters, taken from the usual STDIN/function argument/etc., whatever your language equivalent, comprised of four parts. These parts can be four separate arguments, a quadruple, an array of size 4, etc. For simplicity and consistency throughout the challenge, I will represent the input as a single word.
- An integer
2 ≤ x ≤ 20
that specifies the size of the spiral in terms of "squares" with each printed character representing one "square" in size. Theoretically this could be enormous in scope, but given that we're drawing ASCII art, a safe upper limit on this will be 20 so that it fits somewhat decently on screen. - A single letter of
d u r
orl
, indicating the initial movement from the starting "square" (down, up, right, left). - An optional
c
, indicating "counter-clockwise." If thec
is omitted, assume clockwise rotation for the spiral. - A final integer
1 ≤ y ≤ 10
that specifies how many times to recurse the spiral drawing, using the finish "square" of the previous spiral as the starting "square" of the new one. I'm picking an upper limit of 10 because I want the drawing to finish at some point. - A few example inputs:
20lc5
13d2
2rc1
Of interest, do note that odd values for the size input will result in the @
always being the exact center of a spiral, but even values may have the starting "square" offset in any of the four diagonal directions, dependent upon the direction of initial travel. This can result in some ... interesting ... patterns. See the two even examples below.
Input that doesn't follow the input specification (e.g., 11q#s
) is undefined and I fully expect the program to barf appropriately. :)
Output
Output is an ASCII printable output via language-equivalent STDOUT, with the following specifications:
- The starting "square" (of each recursion) must be marked with an at-sign
@
. - The final "square" must be marked with an ampersand
&
. In the case of multiple recursions, only the very final "square" should be marked&
. - Corners of the spiral path need to "point" in the direction of travel, using
< > v ^
. - Vertical travel need to be drawn by pipes
|
. - Horizontal travel needs to be drawn with dashes
-
. - "Squares" that are overwritten by later recursions should display the most-recent direction of travel. This will result in "newer" recursions seeming to be layered on top of the "older" recursions. See the
4rc3
example below. - A final trailing newline is OK, leading spaces could be a must and so are allowed, but trailing spaces are not allowed.
- I won't dock you if you use escape sequences to draw the ASCII art going to STDOUT, but I will be silently disappointed in you. (You'll still be eligible for the bounty if you use them)
Examples
2d4
= diameter of 2, starts by going down, clockwise, 4 recursions
&@@@@
^<<<<
In this example, the drawing starts in the upper-right @
, goes down one, left one, up one. At this point, we've finished the 2d
portion, and so start the 2nd recursion, so we have another @
, down one, left one, up one; then the 3rd recursion; then the 4th and finally our &
.
4rc3
= diameter of 4, starts by going right, counter-clockwise, 3 recursions
&--<
v-<|
|@^|<
>--^|
|@^|<
>--^|
|@^|
>--^
In this example, the drawing starts in the bottom @
, goes right one, up one, spirals around, until it reaches the middle @
and finishes the 4rc
portion. This then repeats two more times to get the full 3 recursions requested. Note that 4rc1
would be just the upper-left 4x4 block of this example.
7u1
= diameter of 7, starts by going up, clockwise, 1 recursion (note the is the same as the intro)
&>----v
||>--v|
|||>v||
|||@|||
||^-<||
|^---<|
^-----<
Winning & Restrictions
This is Code Golf, so smallest answer in bytes wins. Submissions should be in the usual form of program/function/CJam Code Block/etc. Standard Loophole Restrictions Apply. Professional driver on closed course. If irritation persists, discontinue use and consult your doctor.