Introduction
Long story short: a few days ago I accidentally started knitting a sock and the pretty logical structure of the plain stitches lead me to the idea: Why don't we just ASCII-knit a sock?
Input
The input is an even integer N in the range [2,30]
.
Output
The output is a sock, obviously.
Structure
Because we will only use plain stitches you will only use v
for a downward stitch and >
for a stitch to the right. Let me explain the full structure with an example for N=8
:
vvvvvvvv
vvvvvvvv
vvvvvvvv
vvvvvvvv
vvvvvvvv
vvvvvvvv
vvvvvvvv
vvvvvvvv
vvvvvvvv
vvvvvvvv
vvvvvvvv
vvvvvvvv
vvvvvvv>>>
vvvvvv>>>>>>
vvvvv>>>>>>>>>
vvvv>>>>>>>>>>>>
vvvv>>>>>>>>>>>>>>>>>>>>>>>>
vvvv>>>>>>>>>>>>>>>>>>>>>>>>>>
vvvv>>>>>>>>>>>>>>>>>>>>>>>>>>
vvvv>>>>>>>>>>>>>>>>>>>>>>>>
- The first block is the upper part. It has the width
N
and the heightN*1.5
- Afterwards the heel begins. You subtract one
v
per row from the right side until you haveN/2
as width. Then you addN/2
rows with the widthN/2
beneath to finish the downward knits. Note that it gives a total ofN/2 + 1
rows with the widthN/2
first part:
vvvvvvvv //begin with width N
vvvvvvvv
vvvvvvvv
vvvvvvvv
vvvvvvvv
vvvvvvvv
vvvvvvvv
vvvvvvvv
vvvvvvvv
vvvvvvvv
vvvvvvvv
vvvvvvvv // N*1.5 times
vvvvvvv // reduce
vvvvvv
vvvvv
vvvv // till here
vvvv // repeat N/2 times
vvvv
vvvv
vvvv
- Now the side wards knits begin. You start with the first reduced row, fill
>
till you have the widthN
and add two more. Continue that process including the first row withN/2
width - Fill the rows beneath to that level and add
N*1.5
times>
to that - Let the outer parts as they are and add on the row beneath the first and over the lase two more
>'s
until it is finished
second part:
vvvvvvvv
vvvvvvv>>> //fill to N and add two >
vvvvvv>>>>>> //repeat
vvvvv>>>>>>>>>
vvvv>>>>>>>>>>>> //till here
vvvv>>>>>>>>>>>>>>>>>>>>>>>> //fill to the row above and add N*1.5 times >
vvvv>>>>>>>>>>>>>>>>>>>>>>>>>> //add two more '>' than the row above
vvvv>>>>>>>>>>>>>>>>>>>>>>>>>> //add two more '>' than the row beneath
vvvv>>>>>>>>>>>>>>>>>>>>>>>>
Rules
Trailing new lines are ok.
You can choose between uppercase or lowercase V
but it has to be consistent.
This is code-golf so the shortest code in bytes wins.
Test cases
N=2
vv
vv
vv
v>>>
v>>>>>>
N=4
vvvv
vvvv
vvvv
vvvv
vvvv
vvvv
vvv>>>
vv>>>>>>
vv>>>>>>>>>>>>
vv>>>>>>>>>>>>
N=6
vvvvvv
vvvvvv
vvvvvv
vvvvvv
vvvvvv
vvvvvv
vvvvvv
vvvvvv
vvvvvv
vvvvv>>>
vvvv>>>>>>
vvv>>>>>>>>>
vvv>>>>>>>>>>>>>>>>>>
vvv>>>>>>>>>>>>>>>>>>>>
vvv>>>>>>>>>>>>>>>>>>
N=12
vvvvvvvvvvvv
vvvvvvvvvvvv
vvvvvvvvvvvv
vvvvvvvvvvvv
vvvvvvvvvvvv
vvvvvvvvvvvv
vvvvvvvvvvvv
vvvvvvvvvvvv
vvvvvvvvvvvv
vvvvvvvvvvvv
vvvvvvvvvvvv
vvvvvvvvvvvv
vvvvvvvvvvvv
vvvvvvvvvvvv
vvvvvvvvvvvv
vvvvvvvvvvvv
vvvvvvvvvvvv
vvvvvvvvvvvv
vvvvvvvvvvv>>>
vvvvvvvvvv>>>>>>
vvvvvvvvv>>>>>>>>>
vvvvvvvv>>>>>>>>>>>>
vvvvvvv>>>>>>>>>>>>>>>
vvvvvv>>>>>>>>>>>>>>>>>>
vvvvvv>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
vvvvvv>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
vvvvvv>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
vvvvvv>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
vvvvvv>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
vvvvvv>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
v
orV
interchangeably? I'm going to assume for the moment thatv
is the only one allowed, but allowingV
will effect the byte count \$\endgroup\$