Desenhar um padrão Houndstooth


22

Escreva um programa ou função que leva dois inteiros positivos, uma largura e uma altura, e desenha uma arte ASCII houndstooth padrão de grade com essas dimensões usando essa grade de 25 × 26 texto como a célula de base:

.......#.....#####.......
.......##.....#####......
.......###.....#####.....
.......####.....####.....
.......#####.....###.....
.......######.....##.....
.......#######.....#.....
.......########..........
####################.....
.####################....
..####################...
...####################..
....####################.
.....####################
#.....##############.####
##.....#############..###
###....#############...##
####...#############....#
#####..#############.....
.#####.#############.....
..##################.....
........#####............
.........#####...........
..........#####..........
...........#####.........
............#####........

Portanto, se a entrada fosse 2,1a saída, seria:

.......#.....#####..............#.....#####.......
.......##.....#####.............##.....#####......
.......###.....#####............###.....#####.....
.......####.....####............####.....####.....
.......#####.....###............#####.....###.....
.......######.....##............######.....##.....
.......#######.....#............#######.....#.....
.......########.................########..........
####################.....####################.....
.####################.....####################....
..####################.....####################...
...####################.....####################..
....####################.....####################.
.....####################.....####################
#.....##############.#####.....##############.####
##.....#############..#####.....#############..###
###....#############...#####....#############...##
####...#############....#####...#############....#
#####..#############.....#####..#############.....
.#####.#############......#####.#############.....
..##################.......##################.....
........#####....................#####............
.........#####....................#####...........
..........#####....................#####..........
...........#####....................#####.........
............#####....................#####........

E se a entrada fosse 5,4a saída seria:

.......#.....#####..............#.....#####..............#.....#####..............#.....#####..............#.....#####.......
.......##.....#####.............##.....#####.............##.....#####.............##.....#####.............##.....#####......
.......###.....#####............###.....#####............###.....#####............###.....#####............###.....#####.....
.......####.....####............####.....####............####.....####............####.....####............####.....####.....
.......#####.....###............#####.....###............#####.....###............#####.....###............#####.....###.....
.......######.....##............######.....##............######.....##............######.....##............######.....##.....
.......#######.....#............#######.....#............#######.....#............#######.....#............#######.....#.....
.......########.................########.................########.................########.................########..........
####################.....####################.....####################.....####################.....####################.....
.####################.....####################.....####################.....####################.....####################....
..####################.....####################.....####################.....####################.....####################...
...####################.....####################.....####################.....####################.....####################..
....####################.....####################.....####################.....####################.....####################.
.....####################.....####################.....####################.....####################.....####################
#.....##############.#####.....##############.#####.....##############.#####.....##############.#####.....##############.####
##.....#############..#####.....#############..#####.....#############..#####.....#############..#####.....#############..###
###....#############...#####....#############...#####....#############...#####....#############...#####....#############...##
####...#############....#####...#############....#####...#############....#####...#############....#####...#############....#
#####..#############.....#####..#############.....#####..#############.....#####..#############.....#####..#############.....
.#####.#############......#####.#############......#####.#############......#####.#############......#####.#############.....
..##################.......##################.......##################.......##################.......##################.....
........#####....................#####....................#####....................#####....................#####............
.........#####....................#####....................#####....................#####....................#####...........
..........#####....................#####....................#####....................#####....................#####..........
...........#####....................#####....................#####....................#####....................#####.........
............#####....................#####....................#####....................#####....................#####........
.......#.....#####..............#.....#####..............#.....#####..............#.....#####..............#.....#####.......
.......##.....#####.............##.....#####.............##.....#####.............##.....#####.............##.....#####......
.......###.....#####............###.....#####............###.....#####............###.....#####............###.....#####.....
.......####.....####............####.....####............####.....####............####.....####............####.....####.....
.......#####.....###............#####.....###............#####.....###............#####.....###............#####.....###.....
.......######.....##............######.....##............######.....##............######.....##............######.....##.....
.......#######.....#............#######.....#............#######.....#............#######.....#............#######.....#.....
.......########.................########.................########.................########.................########..........
####################.....####################.....####################.....####################.....####################.....
.####################.....####################.....####################.....####################.....####################....
..####################.....####################.....####################.....####################.....####################...
...####################.....####################.....####################.....####################.....####################..
....####################.....####################.....####################.....####################.....####################.
.....####################.....####################.....####################.....####################.....####################
#.....##############.#####.....##############.#####.....##############.#####.....##############.#####.....##############.####
##.....#############..#####.....#############..#####.....#############..#####.....#############..#####.....#############..###
###....#############...#####....#############...#####....#############...#####....#############...#####....#############...##
####...#############....#####...#############....#####...#############....#####...#############....#####...#############....#
#####..#############.....#####..#############.....#####..#############.....#####..#############.....#####..#############.....
.#####.#############......#####.#############......#####.#############......#####.#############......#####.#############.....
..##################.......##################.......##################.......##################.......##################.....
........#####....................#####....................#####....................#####....................#####............
.........#####....................#####....................#####....................#####....................#####...........
..........#####....................#####....................#####....................#####....................#####..........
...........#####....................#####....................#####....................#####....................#####.........
............#####....................#####....................#####....................#####....................#####........
.......#.....#####..............#.....#####..............#.....#####..............#.....#####..............#.....#####.......
.......##.....#####.............##.....#####.............##.....#####.............##.....#####.............##.....#####......
.......###.....#####............###.....#####............###.....#####............###.....#####............###.....#####.....
.......####.....####............####.....####............####.....####............####.....####............####.....####.....
.......#####.....###............#####.....###............#####.....###............#####.....###............#####.....###.....
.......######.....##............######.....##............######.....##............######.....##............######.....##.....
.......#######.....#............#######.....#............#######.....#............#######.....#............#######.....#.....
.......########.................########.................########.................########.................########..........
####################.....####################.....####################.....####################.....####################.....
.####################.....####################.....####################.....####################.....####################....
..####################.....####################.....####################.....####################.....####################...
...####################.....####################.....####################.....####################.....####################..
....####################.....####################.....####################.....####################.....####################.
.....####################.....####################.....####################.....####################.....####################
#.....##############.#####.....##############.#####.....##############.#####.....##############.#####.....##############.####
##.....#############..#####.....#############..#####.....#############..#####.....#############..#####.....#############..###
###....#############...#####....#############...#####....#############...#####....#############...#####....#############...##
####...#############....#####...#############....#####...#############....#####...#############....#####...#############....#
#####..#############.....#####..#############.....#####..#############.....#####..#############.....#####..#############.....
.#####.#############......#####.#############......#####.#############......#####.#############......#####.#############.....
..##################.......##################.......##################.......##################.......##################.....
........#####....................#####....................#####....................#####....................#####............
.........#####....................#####....................#####....................#####....................#####...........
..........#####....................#####....................#####....................#####....................#####..........
...........#####....................#####....................#####....................#####....................#####.........
............#####....................#####....................#####....................#####....................#####........
.......#.....#####..............#.....#####..............#.....#####..............#.....#####..............#.....#####.......
.......##.....#####.............##.....#####.............##.....#####.............##.....#####.............##.....#####......
.......###.....#####............###.....#####............###.....#####............###.....#####............###.....#####.....
.......####.....####............####.....####............####.....####............####.....####............####.....####.....
.......#####.....###............#####.....###............#####.....###............#####.....###............#####.....###.....
.......######.....##............######.....##............######.....##............######.....##............######.....##.....
.......#######.....#............#######.....#............#######.....#............#######.....#............#######.....#.....
.......########.................########.................########.................########.................########..........
####################.....####################.....####################.....####################.....####################.....
.####################.....####################.....####################.....####################.....####################....
..####################.....####################.....####################.....####################.....####################...
...####################.....####################.....####################.....####################.....####################..
....####################.....####################.....####################.....####################.....####################.
.....####################.....####################.....####################.....####################.....####################
#.....##############.#####.....##############.#####.....##############.#####.....##############.#####.....##############.####
##.....#############..#####.....#############..#####.....#############..#####.....#############..#####.....#############..###
###....#############...#####....#############...#####....#############...#####....#############...#####....#############...##
####...#############....#####...#############....#####...#############....#####...#############....#####...#############....#
#####..#############.....#####..#############.....#####..#############.....#####..#############.....#####..#############.....
.#####.#############......#####.#############......#####.#############......#####.#############......#####.#############.....
..##################.......##################.......##################.......##################.......##################.....
........#####....................#####....................#####....................#####....................#####............
.........#####....................#####....................#####....................#####....................#####...........
..........#####....................#####....................#####....................#####....................#####..........
...........#####....................#####....................#####....................#####....................#####.........
............#####....................#####....................#####....................#####....................#####........
  • O argumento da largura deve vir primeiro. Qualquer formato de entrada razoável (por exemplo w,h, w h, (w, h)) é bom.
  • Imprima ou retorne o resultado com uma nova linha à direita opcional.
  • Você pode usar dois caracteres ASCII imprimíveis distintos no lugar de .e #.
  • Você pode converter a célula base vertical ou horizontalmente, como se tivesse condições de contorno periódicas . Portanto, o canto superior esquerdo da saída não será necessariamente um retângulo 7 × 8 de .'s. ( Nova regra! )

O código mais curto em bytes vence.

Como bônus, gere uma imagem em que cada .um é um pixel de uma cor e cada #um é um pixel de outra cor.


Que tipo de bônus? Um biscoito..? ;-)
Zach Gates

4
Dane-se o seu "menor código ganha", eu estou Befunge'ing isso!
El'endia Starman

7
@ZachGates Talvez um biscoito de cachorro.
Hobbies de Calvin

Maré de rolo a isso!
Greg Bacon

Respostas:


17

Pitão, 61 60 55 49 bytes

j*vwmjk*Qd++Rm012Jmms}k++Rhd5U-d4T=T13+Lm1T_mP_dJ

Experimente online: Demonstração

editar 1: Combine as duas instruções que geram a banda e o triângulo (veja abaixo)

editar 2: não viu que podemos usar qualquer símbolo. Salvo 5 bytes editar

edit 3: @ Calvin'sHobbies permitido traduzir a imagem base. Como minha abordagem foi baseada nessa idéia, isso ajudou bastante. -6 bytes

E para o bônus do Cookie :

.w*vw*RQ++Rm012Jmm*K255}k++Rhd5U-d4T=T13+LmKT_mP_dJ

Isso tem apenas 2 bytes mais (51 bytes) e gera o arquivo o.png. Para a entrada 5\n4, gera a seguinte imagem:

Padrão de Houndstooth

Explicação:

O padrão Houndstooth parece realmente bastante irregular. Mas se trouxemos as 7 colunas da esquerda para a direita e as 5 principais linhas para o botão, obtemos um padrão muito melhor:

.#####...................
..#####..................
...#####.................
....#####................
.....#####...............
#.....#####..............
##.....#####.............
###.....#####............
####.....####............
#####.....###............
######.....##............
#######.....#............
########.................
#############.....#######
##############.....######
###############.....#####
################.....####
#################.....###
##################.....##
#############.#####.....#
#############..#####.....
#############...#####....
#############....#####...
#############.....#####..
#############......#####.
#############.......#####

Primeiro, produzo o bloco 13x13 superior esquerdo:

.#####.......
..#####......
...#####.....
....#####....
.....#####...
#.....#####..
##.....#####.
###.....#####
####.....####
#####.....###
######.....##
#######.....#
########.....

Existem 2 desigualdades simples, que descrevem as duas #áreas. A banda pode ser descrita por y + 1 <= x <= y + 5e o triângulo pode ser descrito por x <= y - 5. Eu combinei essas duas condições:

Jmms}k++Rhd5U-d4T=T13
                 =T13   T = 13
 m               T      map each d of [0, 1, ..., 12] to: 
                           the list produced by
  m             T          map each k of [0, 1, ..., 12] to:
       +Rhd5                  the list [d+1, d+2, ..., d+5]
      +                       extended by 
            U-d4              the list [0, 1, ..., d - 5]
    }k                        test if k is in the list
   s                          and convert the boolean result to 1 or 0
J                       assign this 13x13 block to J

Em seguida, +Rm012adiciona 12 zeros no final de cada linha para obter o bloco superior de 25x13.

O bloco inferior de 25x13 agora é realmente simples:

+Lm1T_mP_dJ
      m   J    map each row d of J to:
       P_d        reverse the row and pop the last element
     _         reverse the order the rows
+Lm1T          add T ones at the beginning of each row. 

Tudo o que resta agora é repetir o padrão e imprimi-lo

j*vwmjk*Qd+upperlower   implicit: Q = first input number
          +upperlower   combine the two blocks to a 25x26 block
    m                   map each row d to:
       *Qd                 repeat d Q times
     jk                    and join to a string
 *vw                    read another number from input and repeat
j                       join by newlines and print

A diferença para o código de bônus do Cookie :

  • 255 ao invés de 1
  • em vez de mjk*Qdusar *RQ, já que não quero uma string
  • .w salva esse array 2D em arquivo (o converte em png implicitamente)

5
Explicação fantástica!
Trichoplax

Você quer dizer claramente "5 linhas inferiores até o topo", é apenas um erro de digitação. Não entendo por que meu comentário foi excluído sem que nenhuma ação seja tomada. Como resultado, tenho vergonha de editar sua postagem agora. Em suma, uma resposta muito boa e uma excelente explicação. Eu já o votei antes
Level River St

@steveverrill Oh, desculpe. Pensei que você quisesse corrigir meu inglês na passagem em que descrevi a transformação de volta. Corrigido agora. Obrigado.
Jakube 22/09

11

CJam, 106 73 71 bytes

0000000: 71 7e 22 04 94 51 af 40 6e 73 b2 68 3a e1 7e 13 f2 a1  q~"..Q.@ns.h:.~...
0000012: 3e 1d de f5 64 9c 6b 0f 27 4c 36 d7 81 3d 30 35 56 f8  >...d.k.'L6..=05V.
0000024: cd e8 cd 7c dc 90 31 59 40 8b 8c 22 32 35 36 62 32 32  ...|..1Y@.."256b22
0000036: 62 41 73 33 39 2a 2e 2a 73 32 35 2f 2a 66 2a 4e 2a     bAs39*.*s25/*f*N*

Imprime 1e em 0vez de .e #. Experimente online no intérprete CJam .

Como funciona

q~      e# Read and evaluate all input. This pushes W and H.
"…"     e# Push an encoding of run lengths of the characters in the output.
256b22b e# Convert from base 256 to base 22.
As39*   e# Push "10" and repeat it 39 times.
.*      e# Vectorized character repetition; multiply each base 22 digit (run
        e# length) by the corresponding character of "10…10".
s25/    e# Flatten and split into chunks of length 25.
*       e# Repeat the resulting array of rows H times.
f*      e# Repeat each row W times.
N*      e# Join the rows, separating by linefeeds.

Bônus de cookie

0000000: 27 50 6f 31 70 71 7e 5d 5f 5b 32 35 5f 29 5d 2e 2a 5c  'Po1pq~]_[25_)].*\
0000012: 7e 22 04 94 51 af 40 6e 73 b2 68 3a e1 7e 13 f2 a1 3e  ~"..Q.@ns.h:.~...>
0000024: 1d de f5 64 9c 6b 0f 27 4c 36 d7 81 3d 30 35 56 f8 cd  ...d.k.'L6..=05V..
0000036: e8 cd 7c dc 90 31 59 40 8b 8c 22 32 35 36 62 32 32 62  ..|..1Y@.."256b22b
0000048: 41 73 33 39 2a 2e 2a 73 32 35 2f 2a 66 2a 73 2b 4e 2a  As39*.*s25/*f*s+N*

imprime um BitMap portátil em vez de ASCII art.

Abaixo está a saída para entrada 24 13, convertida em PNG:

saída


7

Befunge-93 , 2120 1967 bytes

Aqui estão alguns exemplos de alta qualidade, com manipulação de exceção para depuração!

&&00p10pv
v       <
    >94+2*20p        v
>00g|   >                v
    @                >10g>0020gv-1:<
                               >:0`|
                     ,       v    $<
                     +        >v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v
 v_$1-:#^_$20g1-20p55^       >|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>"!DAB"....@
 ,:
 >^".......#.....#####......."                                                    <
  ^".......##.....#####......"                                                  <
  ^".......###.....#####....."                                                <
  ^".......####.....####....."                                              <
  ^".......#####.....###....."                                            <
  ^".......######.....##....."                                          <
  ^".......#######.....#....."                                        <
  ^".......########.........."                                      <
  ^"####################....."                                    <
  ^".####################...."                                  <
  ^"..####################..."                                <
  ^"...####################.."                              <
  ^"....####################."                            <
  ^".....####################"                          <
  ^"#.....##############.####"                        <
  ^"##.....#############..###"                      <
  ^"###....#############...##"                    <
  ^"####...#############....#"                  <
  ^"#####..#############....."                <
  ^".#####.#############....."              <
  ^"..##################....."            <
  ^"........#####............"          <
  ^".........#####..........."        <
  ^"..........#####.........."      <
  ^"...........#####........."    <
  ^"............#####........"  <
^                     p00-1g00<

(Obviamente, isso ainda é muito jogável. Eu só queria obter uma resposta aqui por enquanto)

Então, isso é composto de partes diferentes.

&&00p10p

Este é apenas o inicializador, pega os valores e os armazena

    >94+2*20p
>00g|      > 
    @  

Esta seção redefine a contagem de linhas, para que possamos imprimir outras fotos (de largura) lado a lado. 94+2*está calculando 26, o número de linhas. Além disso, se a altura for zero, o programa será encerrado.

>10g

Isso fica com a largura da pilha, para que possamos saber quantas imprimir

0020gv-1:<
     >:0`|
         $

Isso adiciona dois valores fictícios à pilha para dizer quando terminamos uma operação, bem como em que linha (n) estamos. Isso adiciona n valores à pilha

>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v
|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>|>"!DAB"....@

                                                    <
                                                  <
                                                <
                                              <
                                            <
                                          <
                                        <
                                      <
                                    <
                                  <
                                <
                              <
                            <
                          <
                        <
                      <
                    <
                  <
                <
              <
            <
          <
        <
      <
    <
  <
<

Esta é uma seção de controle que irá para a linha (26-n). Esta é a maneira mais fácil de descobrir como fazê-lo.

".......#.....#####......."
".......##.....#####......"
".......###.....#####....."
".......####.....####....."
".......#####.....###....."
".......######.....##....."
".......#######.....#....."
".......########.........."
"####################....."
".####################...."
"..####################..."
"...####################.."
"....####################."
".....####################"
"#.....##############.####"
"##.....#############..###"
"###....#############...##"
"####...#############....#"
"#####..#############....."
".#####.#############....."
"..##################....."
"........#####............"
".........#####..........."
"..........#####.........."
"...........#####........."
"............#####........"

Obviamente, isso é lido e exibirá qualquer linha lida na pilha de trás para frente. Isso significa que, quando o abrirmos, ele será impresso corretamente.

v_
,:
>^

Isso será impresso até que a pilha atinja um 0, que deixamos anteriormente.

1-:#^_

Isso retira 1 do número da linha específica a ser impressa e verifica se é zero ou não. Se for diferente de zero, voltaremos ao quarto bloco de código.

          ,
          +
20g1-20p55^

Isso subtrai 1 da linha (n), imprime uma nova linha e volta ao bloco 3

p00-1g00

Uma vez impressas todas as linhas, isso subtrai uma da altura inicial e volta para o bloco 2.

Todo o restante do código é fluxo de controle ou gerenciamento de pilha. Escrever esse mas mais do que eu pensava, mas estou satisfeito com a aparência. É muito mais jogável e provavelmente continuará sendo um projeto por mais um dia.

2120 -> 1967 : aparadas algumas linhas com muitos espaços desperdiçados


1
Eu joguei isso. Não é sua resposta especificamente, mas eu joguei uma solução no Befunge!
El'endia Starman 24/09/2015

6

Perl, 243

(Um byte foi adicionado para que o -ncomutador busque entrada de stdin.)

($w,$h)=split;for(1..$h){print((sprintf("%025b",hex)x$w).$/)foreach qw(20f80 307c0 383e0 3c1e0 3e0e0 3f060 3f820 3fc00 1ffffe0 fffff0 7ffff8 3ffffc 1ffffe fffff 107ffef 183ffe7 1c3ffe3 1e3ffe1 1f3ffe0 fbffe0 7fffe0 1f000 f800 7c00 3e00 1f00)}

Isso é bastante simples - basta converter uma matriz de 26 números hexadecimais em binários e imprimi-los o número necessário de vezes.

Exemplo:

Entrada:

3 2

Saída:

000000010000011111000000000000001000001111100000000000000100000111110000000
000000011000001111100000000000001100000111110000000000000110000011111000000
000000011100000111110000000000001110000011111000000000000111000001111100000
000000011110000011110000000000001111000001111000000000000111100000111100000
000000011111000001110000000000001111100000111000000000000111110000011100000
000000011111100000110000000000001111110000011000000000000111111000001100000
000000011111110000010000000000001111111000001000000000000111111100000100000
000000011111111000000000000000001111111100000000000000000111111110000000000
111111111111111111110000011111111111111111111000001111111111111111111100000
011111111111111111111000001111111111111111111100000111111111111111111110000
001111111111111111111100000111111111111111111110000011111111111111111111000
000111111111111111111110000011111111111111111111000001111111111111111111100
000011111111111111111111000001111111111111111111100000111111111111111111110
000001111111111111111111100000111111111111111111110000011111111111111111111
100000111111111111110111110000011111111111111011111000001111111111111101111
110000011111111111110011111000001111111111111001111100000111111111111100111
111000011111111111110001111100001111111111111000111110000111111111111100011
111100011111111111110000111110001111111111111000011111000111111111111100001
111110011111111111110000011111001111111111111000001111100111111111111100000
011111011111111111110000001111101111111111111000000111110111111111111100000
001111111111111111110000000111111111111111111000000011111111111111111100000
000000001111100000000000000000000111110000000000000000000011111000000000000
000000000111110000000000000000000011111000000000000000000001111100000000000
000000000011111000000000000000000001111100000000000000000000111110000000000
000000000001111100000000000000000000111110000000000000000000011111000000000
000000000000111110000000000000000000011111000000000000000000001111100000000
000000010000011111000000000000001000001111100000000000000100000111110000000
000000011000001111100000000000001100000111110000000000000110000011111000000
000000011100000111110000000000001110000011111000000000000111000001111100000
000000011110000011110000000000001111000001111000000000000111100000111100000
000000011111000001110000000000001111100000111000000000000111110000011100000
000000011111100000110000000000001111110000011000000000000111111000001100000
000000011111110000010000000000001111111000001000000000000111111100000100000
000000011111111000000000000000001111111100000000000000000111111110000000000
111111111111111111110000011111111111111111111000001111111111111111111100000
011111111111111111111000001111111111111111111100000111111111111111111110000
001111111111111111111100000111111111111111111110000011111111111111111111000
000111111111111111111110000011111111111111111111000001111111111111111111100
000011111111111111111111000001111111111111111111100000111111111111111111110
000001111111111111111111100000111111111111111111110000011111111111111111111
100000111111111111110111110000011111111111111011111000001111111111111101111
110000011111111111110011111000001111111111111001111100000111111111111100111
111000011111111111110001111100001111111111111000111110000111111111111100011
111100011111111111110000111110001111111111111000011111000111111111111100001
111110011111111111110000011111001111111111111000001111100111111111111100000
011111011111111111110000001111101111111111111000000111110111111111111100000
001111111111111111110000000111111111111111111000000011111111111111111100000
000000001111100000000000000000000111110000000000000000000011111000000000000
000000000111110000000000000000000011111000000000000000000001111100000000000
000000000011111000000000000000000001111100000000000000000000111110000000000
000000000001111100000000000000000000111110000000000000000000011111000000000
000000000000111110000000000000000000011111000000000000000000001111100000000

3

Rev 1, C, 118 115 bytes

i,x,y;f(w,h){for(i=26*h*(w*=25);i--;i%w||puts(""))x=i%25,y=i/w%26,putchar(((y>x^y>x+5^x>y+4)&y/13==x/13^y/13)+34);}

9 bytes salvos devido a nova regra que permite a conversão da célula. 3 bytes salvos pelo uso de w*=25. O restante da postagem permanece inalterado.

Rev 0, C, 127 bytes

i,x,y;f(w,h){for(i=650*w*h;i--;i%(25*w)||puts(""))x=(i+20)%25,y=(i/25/w+8)%26,putchar(((y>x^y>x+5^x>y+4)&y/13==x/13^y/13)+34);}

Isso passa pelos caracteres, imprimindo-os um por um. i%(25*w)||puts("")insere uma nova linha no final de cada linha.

Minha maneira de visualizar o design é semelhante à de Jakube, mas trago as 8 linhas superiores para a parte inferior e as 5 colunas da direita para a esquerda para obter a seguinte visualização. No programa, essa etapa é "revertida" por +20e +8nas expressões para x e y.

"""""####################
#"""""###################
##"""""##################
###"""""#################
####"""""################
#####"""""###############
"#####"""""##############
""#####"""""#############
"""#####""""#############
""""#####"""#############
"""""#####""#############
""""""#####"#############
"""""""##################
"""""""""""""#####"""""""
""""""""""""""#####""""""
"""""""""""""""#####"""""
""""""""""""""""#####""""
"""""""""""""""""#####"""
""""""""""""#"""""#####""
""""""""""""##"""""#####"
""""""""""""###"""""#####
""""""""""""####"""""####
""""""""""""#####"""""###
""""""""""""######"""""##
""""""""""""#######"""""#
""""""""""""########"""""

Além da "inversão de cores", pode parecer muito semelhante, mas há uma diferença importante: as listras diagonais coincidem. (observe que o design original não possui simetria diagonal, pois mede 25x26.)

A expressão ((y>x^y>x+5^x>y+4)^y/13)+34produz o seguinte, onde os vários operadores de comparação produzem as listras, ^y/13produz o "deslocamento da cor" até a metade e +34pega o número resultante 0,1e o eleva para o intervalo ASCII 34,35.

"""""####################
#"""""###################
##"""""##################
###"""""#################
####"""""################
#####"""""###############
"#####"""""##############
""#####"""""#############
"""#####"""""############
""""#####"""""###########
"""""#####"""""##########
""""""#####"""""#########
"""""""#####"""""########
########"""""#####"""""""
#########"""""#####""""""
##########"""""#####"""""
###########"""""#####""""
############"""""#####"""
#############"""""#####""
##############"""""#####"
###############"""""#####
################"""""####
#################"""""###
##################"""""##
###################"""""#
####################"""""

O termo é &y/13==x/13avaliado como false = 0 nos quartos superior direito e inferior esquerdo, produzindo a parte quadrada do padrão, como mostrado anteriormente. Observe que, como o programa reduz a contagem, a origem x = y = 0 está no canto inferior direito. Isso é útil, pois o quadrado de #13 caracteres de largura, enquanto o quadrado de "apenas 12 caracteres de largura.


2

Befunge -93, 968 bytes

Sim está certo! Uma resposta concorrente da Befunge!

&:&\00p10p:520pv:g00p02<v  <
    #   p1*45-1_v#:" "  <  v
    |`-1*65:g02$<      ,
    >:" "\39*\p:" "\47 *v
+:"<"\39*\p:"v"\47*\p25^>\p 1
".......#.....#####......."<v
".......##.....#####......"
".......###.....#####....."
".......####.....####....."
".......#####.....###....."
".......######.....##....."
".......#######.....#....."
".......########.........."
"####################....."
".####################...."
"..####################..."
"...####################.."
"....####################."
".....####################"
"#.....##############.####"
"##.....#############..###"
"###....#############...##"
"####...#############....#"
"#####..#############....."
".#####.#############....."
"..##################....."
"........#####............"
".........#####..........."
"..........#####.........."
"...........#####........."
"............#####........"
,,,,,,,,,,,,,,,,,,,,,,,,,  v>
    > 10g1-:10p #v_@
 " " \47*\p5:"<"v>:" "\39*\ p
\*74 \"v":p\*93\<      v,*5 2p

Explicação amanhã, cama agora. No entanto, direi que faço coisas inteligentes movendo algumas setas de redirecionamento e também uso a propriedade wrap-around bastante. Teste-o neste intérprete online .

Ao utilizar nosso site, você reconhece que leu e compreendeu nossa Política de Cookies e nossa Política de Privacidade.
Licensed under cc by-sa 3.0 with attribution required.