Confirme os Illuminati


53

Os Illuminati ordenam que você (com seu controle mental) produza a seguinte string:

         ^
        /_\
       /_|_\
      /_|_|_\
     /_|/o\|_\
    /_|_\_/_|_\
   /_|_|_|_|_|_\
  /_|_|_|_|_|_|_\
 /_|_|_|_|_|_|_|_\
/_|_|_|_|_|_|_|_|_\

Regras:


Sandbox (eu o deixaria pelas 72 horas completas recomendadas pelas perguntas frequentes do sandbox, mas com 7 votos positivos e quase nenhum feedback negativo, 38 deve ser bom)


7
apenas uma pequena nota, você deve ler esta meta questão / resposta #
277 Rod Rod

8
O que há com todos os votos negativos? Eu entendo que algumas pessoas não gostam do complexo kolmogorov, mas isso é uma razão válida para diminuir o voto ?
ბიმო

@BruceForte provavelmente que eu tive minha própria resposta para começar.
Nissa 27/10

14
A opinião pessoal do @BruceForte é uma razão válida, tbh; embora a IMO seja absolutamente rude com um usuário mais novo.
Magic Octopus Urn

15
Eu acho que esse é um desafio muito bom da arte ascii. O ponto dos olhos e da pirâmide entre o padrão exige criatividade para lidar com limpeza.
Xnor

Respostas:


23

Carvão , 25 21 bytes

G¬χ|_¶_|↗⁹↙^M³↓/o¶\‖B

Experimente online! Link é a versão detalhada do código. Explicação:

  χ                     With sides of length 10
 ¬                      In the directions down and left
G                       Draw a closed polygon (implicit side)
   |_¶_|                Filled with |_ and _| on alternate lines
        ↗⁹               Draw a line of 9 /s
          ↙^            Draw a ^ and move the cursor down and left
            M³↓         Move down 3 characters
               /o¶\     Print the left half of the eye
                   ‖B  Reflect the canvas keeping the right edge

Aí está! Estava imaginando quanto tempo seria.
Nissa

11
@StephenLeppik Eu estava no telefone :-(
Neil

Espere, esse é o único motivo?
Nissa

@StephenLeppik: bem, isso e dependendo de quanto tempo antes eu notei a notificação para um novo post principal, eu acho.
Neil

O @DLosc <é um dos multidirecionais - quando usado com o Multiprintcomando, ele faz com que a string seja impressa duas vezes, uma para a direita e outra para a direita, mas também pode ser usada como atalho para ↗↘outros contextos.
Neil


10

V , 37 bytes

9i|_á\|r/òÄó_|
>òC ^4jhR/o\j2hR\_/

Experimente online!

Hexdump:

00000000: 3969 7c5f 1be1 5c7c 722f f2c4 f35f 7c0a  9i|_..\|r/..._|.
00000010: 3ef2 4320 5e1b 346a 6852 2f6f 5c1b 6a32  >.C ^.4jhR/o\.j2
00000020: 6852 5c5f 2f                             hR\_/

Explicação:

9i                              " Insert 9 copies of...
  |_                            "   '|_'
    <esc>                       " Return to normal mode
         á\                     " Append a backslash
           |                    " Move to the first character
            r/                  " Replace it with a forward slash
              ò                 " Recursively...
               Ä                "   Duplicate this line (upwards)
                ó               "   Remove one instance of..
                 _|             "     '_|'
>                               "   Indent this line with one space
 ò                              " End the loop
  C ^                           " Change this line (previously '/_\') to ' ^'
     <esc>                      " Return to normal mode
          4j                    " Move down 4 lines
            h                   " Move one character to the left
             R                  " Write this text over existing characters...
              /o\               "   '/o\'
                 <esc>          " Return to normal mode
                      j         " Move down a line
                       2h       " Move two characters to the left
                         R      " Write this text over existing characters...
                          \_/   " '\_/'

10

SOGL V0.12 , 31 27 25 bytes

 ^9∫Ƨ_|m└Κ}¹±§"/o¶\_”95žΓ

Experimente aqui!

 ^                         push "^"
  9∫      }                do 9 times, pushing counter
    Ƨ_|                      push "_|"
       m                     mold that to the counter
        └Κ                   prepend "/"
           ¹               collect the lines in an array - ["^", "/_", "/_|", ..., "/_|_|_|_|_"]
            ±              reverse each                    ["^", "_/", "|_/", ..., "_|_|_|_|_/"]
             §             reverse as ascii-art:
                            ["         ^",
                             "        /_",
                             "       /_|",
                             ...,
                             "/_|_|_|_|_"]
              "/o¶\_”      push "/o
                                 \_"
                     95ž   insert that at [9; 5]
                        Γ  palindromize horizontally

ou uma versão de 24 bytes usando ¼(espaço para um antidiagonal) em vez de ±§:

 ^9∫Ƨ_|m└Κ}¹¼"/o¶\_”95žΓ

Experimente aqui!


8

Python 2 , 103 101 98 95 bytes

-2 bytes graças a Jonathan Frech
-3 bytes graças a ovs

for i in range(10):print(9-i)*' '+['^','/_%s\\'%['|_'*~-i,'|/o\|_','|_\_/_|_'][i%6/4*i%3]][i>0]

Experimente online!


8

JavaScript (ES6), 95 92 bytes

f=(n=9,s='')=>n--?f(n,s+' ')+s+`/${n-4?n-3?'_|'.repeat(n):'_|/o\\|':'_|_\\_/_|'}_\\
`:s+`^
`

Ou 91 bytes com uma nova linha líder - o que eu acho que não é permitido:

f=(n=9,s=`
`)=>n--?f(n,s+' ')+s+`/${n-4?n-3?'_|'.repeat(n):'_|/o\\|':'_|_\\_/_|'}_\\`:s+`^`

Demo

Formatado e comentado

f = (n = 9, s = '') =>    // n = line counter, s = leading spaces
  n-- ?                   // if we haven't reached the top:
    f(n, s + ' ') +       //   do a recursive call with one more leading space
    s +                   //   append the leading spaces
    `/${                  //   append the left border
      n - 4 ?             //   if this is not the 4th row:
        n - 3 ?           //     if this is not the 3rd row:
          '_|'.repeat(n)  //       append the brick pattern
        :                 //     else (3rd row):
          '_|/o\\|'       //       append the top of the eye
      :                   //   else (4th row):
        '_|_\\_/_|'       //     append the bottom of the eye
    }_\\\n`               //   append the right border + line-feed
  :                       // else:
    s + `^\n`             //   append the top of the pyramid and stop the recursion

Os espaços em branco à esquerda são permitidos.
N17

8

C (gcc) , 124 122 120 119 117 115 118 bytes

-1 byte graças a @xanoetux +3 em falta no nível mais baixo ...

f(i){for(printf("%*c",i=10,94);--i;printf("\n%*c%s_\\",i,47,i^6?i^5?"_|_|_|_|_|_|_|_|_|"+i*2:"_|_\\_/_|":"_|/o\\|"));}

Experimente online!


5

Haskell, 110 107 bytes

"         ^\n"++do z<-[1..9];([z..8]>>" ")++'/':g z++"_\\\n"
g 4="_|/o\\|"
g 5="_|_\\_/_|"
g x=[2..x]>>"_|"

Experimente online!

Aqueles 9 espaços no começo doem.

Como funciona

"         ^\n"++         -- first line, followed by
do                       -- we use the "do" syntatic sugar for monads,
                         -- here the list monad 
   z<-[1..9]             -- for all 'z' from [1..9] perform the following
                         -- and collect the results in a single list
     ([z..8]>>" ")++'/'  --   make the spaces for the current line and
                         --   the left wall '/'
     g z                 --   call g to make the inner part
     "_\\\n"             --   append '_', '\' and a NL

g 4="_|/o\\|"            -- line 4 and 5 are implemented directly
g 5="_|_\\_/_|"
g x=[2..x]>>"_|"         -- all other lines are some copies of "_|"

Edit: -3 bytes graças a @Laikoni:



3

05AB1E , 47 42 40 bytes

'/„_|ûûû«η'^0ǝ.∞.C":;<IJK"Çv"/o\\_/"Nèyǝ

Experimente online!

'/„_|ûûû«                                # Push bottom left tier of pyramid.
         η                               # All prefixes of...
          '^0ǝ                           # Replace the tip.
              .∞.C                       # Mirror, Center.
                  ":;<IJK"Ç              # Push [58,59,60,73,74,75].
                           v"/o\\_/"Nèyǝ # Replace those indexes with the eye.

Versão estúpida: „_|3×"_|/o\|".;„_|2×û"_|_\_/_".;


Outra versão menos estúpida (mas ainda pior):

05AB1E , 42 bytes

•~µÎт•η4¾ǝ•Σ}•4ǝ•3x1•5ǝεS"|_/\^o"sèJ}€.∞.C

Experimente online!


2

Bubblegum , 48 bytes

00000000: 5380 8138 2e18 4b3f 3e86 0bce ac01 72e0  S..8..K?>.....r.
00000010: 6c30 0fc6 d1cf 8f01 71e1 cae2 218a e12a  l0......q...!..*
00000020: 6ba0 ea61 7c84 085c 0021 0417 4188 0100  k..a|..\.!..A...

Experimente online!


2

PHP, 123 + 3 bytes

+3 bytes para a contagem de separadores estranhos. (ainda move o cursor 8 espaços em qualquer console!)

for($i=10;--$i;)$r.=str_pad(str_pad("
",$i)."/",20-$i,"_|")."\\";$r[48]=$r[65]="/";$r[50]=$r[63]="\\";$r[49]=o;echo"   ^$r";

Nota: O primeiro caractere depois echo"é um caractere de tabulação!

Corra com -nrou experimente online .

outra versão, mesmo comprimento:

for(;$i++<9;)$r.=str_pad(str_pad("
",10-$i)."/",10+$i,"_|")."\\";$r[48]=$r[65]="/";$r[50]=$r[63]="\\";$r[49]=o;echo"    ^$r";

E o Eclipse? Eu não o uso há algum tempo, mas lembro que suas abas eram 4 espaços.
Nissa

@StephenLeppik O Eclipse é um editor, não um shell.
Titus

Ainda possui um console. Para não mencionar que o editor SE remarcação e <pre> fonte tag ambos têm guias 4-espaciais
Nissa


2

Ruby, 92 bytes

10.times{|i|s=' '*(10-i)+(i<1??^:"/#{"_|"*~-i}_\\");i/2==2&&s[9,3]="/o\\_/"[i%2*2,3];puts s}

2

Excel VBA, 104 bytes

Função de janela imediata VBE anônima que confirma a verdade.

Versão A:

?Spc(9)"^":For i=0To 8:[A1]=i:?Spc(8-i)"/_"[If(A1=3,"|/o\|_",If(A1=4,"|_\_/_|_",Rept("|_",A1)))]"\":Next

Versão B:

?Spc(9)"^":For i=0To 8:[A1]=i:?Spc(8-i)"/_"IIf(i=3,"|/o\|_",IIf(i=4,"|_\_/_|_",[Rept("|_",A1)]))"\":Next

2

Python 2 , 154 bytes

l=bytearray
a,b=' _';g=[l(a*9+"^"+a*9)]+[l(a*(8-k)+"/%s\\"%"|".join(b*k+b))for k in range(9)]
g[4][8:11]=l("/o\\")
g[5][8:11]=l("\\_/")
for r in g:print r

Experimente online!

-3 bytes usando bytearraygraças ao Rod
-1 byte graças ao bobrobbob


1

Javascript 90 bytes (se o parâmetro padrão a = 9 for necessário, então 92 bytes)

A=(a,x=``)=>a?A(a-1,x+" ")+x+"/".padEnd(a*2,a^5?a^4?"_|":"_|/o\\|":"_|_\\_/")+`\\
`:x+`^
`
console.log(A(9))


Todos os argumentos estranhos devem ser incluídos no total de bytes para que isso conta como 91 bytes
Nissa

1

Java 8, 156 bytes

v->"".format("%1$9s^\n%1$8s/a%1$7s/ba%1$6s/bba     /b/o\\|a    /b_\\_/ba   /bbbbba  /bbbbbba /bbbbbbba/bbbbbbbba","").replace("a","_\\\n").replace("b","_|")

Explicação:

Experimente aqui.

v->                        // Method with empty unused parameter and String return-type
  "".format(               //  Format the following String (`%1$Ns` = N spaces)
      "%1$9s^\n            //            ^
       %1$8s/a             //           /_\
       %1$7s/ba            //          /_|_\
       %1$6s/bba           //         /_|_|_\
            /b/o\\|a       //        /_|/o\|_\
           /b_\\_/ba       //       /_|_\_/_|_\
          /bbbbba          //      /_|_|_|_|_|_\
         /bbbbbba          //     /_|_|_|_|_|_|_\
        /bbbbbbba          //    /_|_|_|_|_|_|_|_\
       /bbbbbbbba","")     //   /_|_|_|_|_|_|_|_|_\
    .replace("a","_\\\n")  //  Replace all "a" with "_\" + new-line
    .replace("b","_|")     //  Replace all "b" with "_|"
                           // End of method (implicit / single-line return-statement)


1

Julia, 152 141 139 130 127 120 113 112 bytes

q="_|";a+b=" "^a*b;a\b=replace(a,q^3,q*b,1);~n=n<0?9+"^\n":~(n-1)*(8-n+"/$(q^n)_\\\n");print(~8\"/o\\|"\"_\\_/")

Explicado:

#Define constant q to abbreviate this string
q="_|";

#Redefine the addition operator to compactly provide whitespace 
#where needed
a+b=" "^a*b;

#Redefine the inverse division operator so we can substitute 
#"_|_|_|" with "_|"*b very compactly
a\b=replace(a,q^3,q*b,1);

#Redefine the bitwise not operator to generate pyramid layers
#Defines them recursively, calling itself to generate previous 
#layers before appending its own. 
#The base case generates the tip. 
~n=n<0?9+"^\n":~(n-1)*(8-n+"/$(q^n)_\\\n");

#Print to output
print(

    #Pyramid with 8 body layers
    ~8

    #Then patch in the eye
    \"/o\\|"
    \"_\\_/"
)

1

C # (.NET Core) , 174 153 bytes

()=>string.Format(@"{1,10}
{0,10}\
{0,9}{2}{3,10}{2}{0,7}|/o\{2}{3,8}\_/_{2}{0,5}{4}  {3}{4} {3}|_{4}{3}|_|_{4}","/_","^",@"|_\
","/_|_",@"|_|_|_|_|_\
")

Experimente online!

Uma maneira ineficiente de construir a pirâmide, mas interessante trabalhar com ela.

Reconhecimentos

-21 bytes graças a @someone



0

JavaScript, 117 bytes

Eu sei para um fato que eu não estou batendo qualquer um dos idiomas de golfe, mas pelo menos eu posso dar a minha própria solução.

$=>[...Array(10)].map((e,i)=>' '.repeat(9-i)+(i--?`/${['_|/o\\|','_|_\\_/_|'][i-3]||'_|'.repeat(i)}_\\`:'^')).join`
`

Aqui está uma demonstração:

var f = $=>[...Array(10)].map((e,i)=>' '.repeat(9-i)+(i--?`/${['_|/o\\|','_|_\\_/_|'][i-3]||'_|'.repeat(i)}_\\`:'^')).join`
`;
console.log(f());
console.log(f.toString().length);

Explicação:

$=>                                       // outer function start
[...Array(10)]                            // create an array to map
.map(…)                                   // map it
    (e,i)=>                               // mapping function start
    ' '.repeat(9-i)                       // spaces for padding
    +(i--?…:'^')                          // use the carat if at the top of the pyramid
        `/${…}_\\`                        // otherwise, make the sides + steps
            ['_|/o\\|','_|_\\_/_|'][i-3]  // use the patterns for the eye, if in the correct rows
            ||'_|'.repeat(i)              // otherwise, make the "bricks" structure
.join`
`                                         // join all the rows into a string (yes this part has a newline in it)

4
Não é recomendável responder imediatamente, deixar que as pessoas façam suas próprias soluções.
Okx 27/10/17

0

Javascript, 238 bytes

Minha primeira tentativa de codegolfing: D

var f=()=>{let b=x=>' '.repeat(x),g='\\',h='/',i=1,st=[(b(9)+'^').split('')];for(;i<10;i++)st.push((b(9-i)+h+st.map(i=>'_').join('|')+g).split(''));st[4][8]=st[5][10]=h;st[4][9]='o';st[5][8]=st[4][10]=g;return st.map(s=>s.join('')).join('\n');}

document.getElementById("display").innerHTML = f();
console.log(f.toString().length);
<pre id="display">
</pre>


11
Bem vindo ao site!
caird coinheringaahing

A codificação permanente é definitivamente mais curta do que o que você tem aqui. Você pode encurtar este com algumas características ES6: function`s` em vez de function('s'), a=>em vez de ()=>, fill(x)em vez de map(e=>x), [...s]em vez de s.split(''), mover uma declaração na forinicialização, etc.
Nissa
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.