Introdução
Para encurtar a história: alguns dias atrás, acidentalmente, comecei a tricotar uma meia e a estrutura lógica dos pontos simples me levou à ideia: por que não tricotamos apenas uma meia em ASCII?
Entrada
A entrada é um número inteiro N no intervalo [2,30]
.
Resultado
A saída é uma meia, obviamente.
Estrutura
Como usaremos somente pontos simples, você usará apenas v
para um ponto descendente e >
um ponto à direita. Deixe-me explicar a estrutura completa com um exemplo para N=8
:
vvvvvvvv
vvvvvvvv
vvvvvvvv
vvvvvvvv
vvvvvvvv
vvvvvvvv
vvvvvvvv
vvvvvvvv
vvvvvvvv
vvvvvvvv
vvvvvvvv
vvvvvvvv
vvvvvvv>>>
vvvvvv>>>>>>
vvvvv>>>>>>>>>
vvvv>>>>>>>>>>>>
vvvv>>>>>>>>>>>>>>>>>>>>>>>>
vvvv>>>>>>>>>>>>>>>>>>>>>>>>>>
vvvv>>>>>>>>>>>>>>>>>>>>>>>>>>
vvvv>>>>>>>>>>>>>>>>>>>>>>>>
- O primeiro bloco é a parte superior. Tem a largura
N
e a alturaN*1.5
- Depois o calcanhar começa. Você subtrai um
v
por linha do lado direito até ter aN/2
largura. Em seguida, adicioneN/2
linhas com a larguraN/2
abaixo para finalizar as malhas descendentes. Observe que ele fornece um total deN/2 + 1
linhas com a larguraN/2
primeira parte:
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
- Agora as malhas laterais começam. Você começa com a primeira linha reduzida, preenche
>
até ter a larguraN
e adicione mais duas. Continue esse processo, incluindo a primeira linha comN/2
largura - Preencha as linhas abaixo desse nível e adicione
N*1.5
tempos>
a esse - Deixe as partes externas como estão e adicione na linha abaixo da primeira e sobre o lase mais duas
>'s
até terminar
segunda parte:
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>>>>>>>>>>>>>>>>>>>>>>>>
Regras
Trailing novas linhas estão ok.
Você pode escolher entre maiúsculas ou minúsculas V
mas deve ser consistente.
Isso é código-golfe portanto o código mais curto em bytes vence.
Casos de teste
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
ou V
alternadamente? Eu vou assumir por um momento que v
é a única permitida, mas permitindo que V
efetuará a contagem de bytes