Golf um quine mútuo


38

Usando dois idiomas de sua escolha, escreva o menor " quine mútuo " possível.

Ou seja, escreva um programa P na linguagem A que emita o código-fonte para um programa Q na linguagem B, de modo que a saída do programa Q seja idêntica ao código-fonte para P.

Os arquivos vazios não contam, nem os programas no estilo "ler o arquivo de origem e imprimi-lo".

Edit: Respostas com P = Q não contam mais.


9
Aliás, isso deve impedir os casos em que as fontes correspondem. Por exemplo, 1é um quine em vários idiomas. Então você pode dizer que é um programa J que imprime um programa Golfscript que imprime um ...... e assim por diante.
Cthom06 16/05

você pode adotar a regra "Tente evitar ou não use envios de 1 byte como este, pois isso estraga toda a diversão". de codegolf.stackexchange.com/questions/1393/…
Ming-Tang

2
Uma solução Brainfuck + Befunge deve ser lançada.
pyon

A linguagem A = linguagem B?
Programmer5000

Como se trata de golfe, você pode esclarecer os critérios de pontuação? Por exemplo, a pontuação final é a soma das contagens de bytes de P e Q? Ou o mínimo da contagem de bytes de P e Q?
b_jonas

Respostas:


15

> <> (Peixe) e Python - 26 caracteres

"00gr00g:a9*2+$' tnirp'>o<

Gera este Python

print "\"00gr00g:a9*2+$' tnirp'>o<"

Você tem um problema com o> <> código porque "e 'permitir análise de cadeia, por isso, todo o programa é apenas empurrado na pilha e nunca exibido.
Kevin Brown

2
@ Bass5098 É exatamente assim que tudo funciona. O primeiro "ativa a análise de cadeias. Ele lê o programa inteiro e, em seguida, volta para o primeiro "e executa o programa sozinho na pilha
cthom06 17-11

Corrigido o problema no meu intérprete. Seu código> <> é emitido print \00gr00g:a9*2+$' tnirp'>o<após o tempo limite. Tenho certeza de que isso ocorre porque gcopia o conteúdo real da célula, mas ogera a versão ASCII do caractere e "não é um código de caractere ASCII válido. ideone.com/kaM0r
Kevin Brown

5
@ Bass5098 "é ASCII 34. Seu intérprete deve estar desligado.
Cthom06 18/05

31

Python e Ruby, 39 caracteres

Este fragmento do Python

s='puts %%q{s=%r;print s%%s}';print s%s

gera esse snippet do Ruby

puts %q{s='puts %%q{s=%r;print s%%s}';print s%s}

que gera o snippet inicial do Python novamente:

$ diff -s mutualquine.py <(ruby <(python mutualquine.py))
Files mutualquine.py and /dev/fd/63 are identical

Observe que isso é semelhante à resposta de JB .


23

C e Perl, 73

Este C:

main(s){printf(s="print q<main(s){printf(s=%c%s%c,34,s,34);}>",34,s,34);}

... gera o seguinte Perl:

print q<main(s){printf(s="print q<main(s){printf(s=%c%s%c,34,s,34);}>",34,s,34);}>

... que gera o C de volta.


1
Salvar 4 bytes:main(s){printf(s="print q<main(s){printf(s=%c%s%1$c,34,s);}>",34,s);}
MD XF

14

C e C ++, 123 caracteres


Este C (compilável com o gcc v4.3.4):

#include <stdio.h>
main(){char *c="#include <stdio.h>%cmain(){char *c=%c%s%c;printf(c,10,34,c,34);}";printf(c,10,34,c,34);}

gera este C ++ (idêntico) (compilável com g ++ 4.3.4, um aviso):

#include <stdio.h>
main(){char *c="#include <stdio.h>%cmain(){char *c=%c%s%c;printf(c,10,34,c,34);}";printf(c,10,34,c,34);}

Isso está dentro das regras publicadas. : P E, como o de Ventero, isso se baseia na resposta de JB .


1
OK, estava dentro das regras postadas até a edição dizendo que as fontes não podem ser as mesmas. Uma pequena alteração poderia corrigir isso, mas não estou inclinado a incentivar essas edições tardias.
Matthew Leia

9

Java para Python - 219

Java:

class Q{public static void main(String[]a){char q=34,c=39;String s="print%sclass Q{public static void main(String[]a){char q=34,c=39;String s=%s%s%s;System.out.printf(s,c,q,s,q,c);}}%s";System.out.printf(s,c,q,s,q,c);}}

Python:

print'class Q{public static void main(String[]a){char q=34,c=39;String s="print%sclass Q{public static void main(String[]a){char q=34,c=39;String s=%s%s%s;System.out.printf(s,c,q,s,q,c);}}%s";System.out.printf(s,c,q,s,q,c);}}'

Faz uso do fato de que python permite 'seqüências de caracteres; isso facilita a gravação da fonte do programa java no programa python.


3
+1 por fazer o trabalho sujo na pior linguagem de golfe de todos os tempos. : P
cjfaure

8

Python + Piet one-liners: 417 caracteres + 7391 7107 executando codels

Este script Python produz uma imagem 7393 x 2; o bloco 2x2 mais à direita do qual é um "sentinela" que encerra o programa; então não estou contando isso; e a segunda linha é branca. Provavelmente, eu posso aprofundar ainda mais o código do piet usando cadeias de adição / subtração / multiplicação em vez do ingênuo algoritmo binário ... mas não quero dar uma solução para um futuro quebra-cabeça.

Não vou postar a imagem aqui, por causa de suas dimensões ridículas. Se você quiser vê-lo, execute o código python e canalize a saída para um arquivo .ppm. Em seguida, converta o .ppm em um .gif e execute a saída no Rapapaing . (alternativamente, use um intérprete Piet que não seja da Web e que gere .ppm)

A='P=lambda A:reduce(lambda(D,H,B),P:(D[P/3:]+D[:P/3],H[P%3*2:]+H[:P%3*2],B+"".join("%i "%H[(D[0]/P)%2]for P in[1,2,4])),map(" A !        @    B".find,A),([1,3,2,6,4,5],[0,192,192,255,0,255],"P3 %i 2 255 "%(len(A)+2)))[2]+"255 "*4+"0 0 "+"255 "*len(A)*3+"255 0 0 "*2;B=lambda D:["@!%s","@@!%s!"][D%2]%B(D/2)if 1<D else"";print P("".join("A%sB"%B(ord(D))for D in"A=%s;exec A[:-13]"%`A`)+" ");exec A[:-13]';exec A[:-13]

edit: jogou um pouco a piet ao reduzir o peso de Hamming dos nomes das variáveis.

menos golf pre-quine :

Esta é uma versão anterior, antes que eu percebesse que poderia transformá-la em uma linha. É um pouco mais fácil de entender. A função P converte um conjunto de instruções especiais em Piet; e a função p pega um número inteiro e produz uma sequência de instruções para criar esse número inteiro na pilha. Eu só estou usando as instruções =,+,:,|, então isso provavelmente poderia ser mais eficiente ... mas eu meio que gosto de ter um compilador Piet completo (das sortes) na fonte.

s="""def P(s):
 l=len(s)+1;R="P3 %i 2 255 "%(l+2);C=[1,3,2,6,4,5];V=[0,192,192,255,0,255]
 for x in map("=|^+-*/%~>.,:@$?#!".find,"="+s):
  C=C[x//3:]+C[:x//3];V=V[x%3*2:]+V[:x%3*2]
  for i in [1,2,4]:R+="%i "%V[(C[0]//i)%2]
 return R+"255 "*4+"0 0 "+"255 "*l*3+"255 0 0 "*2
p=lambda x:[":+%s","::+%s+"][x%2]%p(x/2)if x/2 else""
print P("".join("|%s!"%k(ord(c))for c in "s="+`s`+";exec s[:-13]"))
exec s[:-13]"""
exec s[:-13]

Piet Creator é um IDE muito mais agradável (e muito menos com erros). Escrito por um usuário deste site , por sinal :)
Joey

Eu usei o Piet Creator antes; é uma ótima ferramenta. O rapapaing é bom para pessoas preguiçosas, como eu, e que não querem se preocupar. FWIW, eu usaria o Piet Creator se você o executasse no github.com/kripken/emscripten/wiki e colocasse isso na sua página.
Boothby

Eu não poderia mesmo obter a versão Qt para compilar aqui;)
Joey

;) Obrigado por tentar, de qualquer maneira. Escrevi-lhe um testador de fuzz: codegolf.stackexchange.com/questions/2922/...
Boothby

Bem, você poderia picar Casey no chat e apontá-lo a ele ;-)
Joey

5

/Brainf..k/, 6988 bytes

Brainfuck

++++++++++>>>+>>>++++++++++>>>+++++++++++>>>++++++>>>+++++++>>>++>>>++++++>>>+++++++>>>+++++++++++>>>++++++>>>+++++++>>>++++++++++>>>+>>>++++++++>>>+>>>++++++++++>>>+++++++++++>>>++>>>+++++++++>>>+>>>++>>>++++++>>>+>>>+>>>+>>>+>>>+>>>++>>>+>>>++>>>+>>>++>>>+>>>++>>>+>>>++>>>++>>>++++++++++>>>+++++++++++>>>++>>>++++++++++>>>+++++++++++>>>++>>>++++++++++>>>+++++++++++>>>++>>>+++++++>>>++>>>++++++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>++>>>++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>++>>>++>>>+++++++>>>++>>>++++++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>++>>>++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>++>>>+>>>++>>>++>>>+++++++>>>++>>>++++++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>++>>>++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>++>>>+>>>++>>>++>>>+++++++>>>++>>>++++++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>++>>>++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>++>>>++>>>+++++++>>>++>>>++++++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>++>>>++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>+>>>+>>>++>>>+>>>++>>>+>>>++>>>++>>>++++++++++>>>+++++++++++>>>+>>>++>>>++>>>++++++++++>>>+++++++++++>>>++>>>+++++++>>>++>>>++++++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>++>>>++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>++>>>+>>>++>>>++>>>+++++++>>>++>>>++++++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>++>>>++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>+>>>+>>>+>>>++>>>+>>>++>>>+>>>++>>>++>>>++++++++++>>>+++++++++++>>>+>>>++>>>++>>>++++++++++>>>+++++++++++>>>++>>>++++++++++>>>+++++++++++>>>+>>>++>>>++>>>+++++++>>>++>>>++++++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>++>>>++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>++>>>+>>>++>>>++>>>+++++++>>>++>>>++++++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>++>>>++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>+>>>+>>>+>>>++>>>+>>>++>>>+>>>++>>>+>>>++>>>+>>>++>>>++>>>++>>>++++++++++>>>+++++++++++>>>++++++++++>>>+++++++++++>>>++>>>++++++++++>>>+++++++++++>>>++>>>+++++++>>>++>>>++++++++++>>>+>>>++++++>>>++++++++++>>>+++++++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>++>>>+>>>++>>>++>>>+++++++>>>++>>>+++++++++++>>>+++++++++++>>>+++++++++++>>>+++++++++++>>>+++++++++++>>>+++++++++++>>>+++++++++++>>>+++++++++++>>>+++++++++++>>>+++++++++++>>>++++++++++>>>+++++++++++>>>+>>>++++++++++>>>+++++++++++>>>++++++>>>+>>>++++++>>>+++++++>>>++>>>++++++>>>+++++++>>>++++++++++>>>+>>>++++++++++>>>+++++++++++>>>++++++>>>+++++++>>>++>>>++++++>>>+++++++>>>+++++++++++>>>++++++++++>>>+++++++++++>>>+++++++>>>++>>>+>>>++++++>>>+++++++>>>++++++>>>+++++++>>>++>>>++++++>>>+++++++>>>++++++++++>>>+>>>++++++++++>>>+++++++++++>>>++++++>>>+++++++>>>++>>>++++++>>>+++++++>>>+++++++++++>>>++++++++++>>>+++++++++++>>>++++++>>>+++++++>>>++++++++++>>>+>>>++++++++++>>>+++++++++++>>>++++++++>>>+>>>++>>>+++++++++>>>++>>>++++++>>>+++++++>>>+>>>+>>>+>>>+>>>+>>>+>>>++>>>+>>>++>>>+>>>++>>>++>>>++++++++++>>>+++++++++++>>>+>>>++>>>++>>>++>>>++++++++++>>>+++++++++++>>>++++++++++>>>+++++++++++>>>++>>>++++++++++>>>+++++++++++>>>+>>>++>>>++>>>++++++>>>+++++++>>>+++++++++++>>>++++++++++>>>+++++++++++>>>++++++>>>+++++++>>>+>>>+>>>+>>>+>>>++++++++++>>>+++++++++++>>>++>>>+>>>+>>>+>>>+>>>++>>>+>>>++>>>+>>>++>>>++>>>++>>>++++++++++>>>+++++++++++>>>++++++++++>>>+++++++++++>>>++>>>++++++++++>>>+++++++++++>>>+>>>++>>>++>>>++>>>++>>>++++++>>>+++++++>>>+++++++++++>>>++++++++++>>>+++++++++++>>>+>>>++++++++>>>+++++++++>>>++>>>++++++++++>>>+>>>+>>>+>>>++++++++++>>>+++++++++++>>>++++++++>>>+>>>++>>>+++++++++>>>++>>>++++++>>>++++++++++>>>+>>>++++++++++>>>+++++++++++>>>++++++++>>>+>>>++>>>+++++++++>>>++++++>>>+>>>++++++++++>>>+++++++++++>>>++++++>>>+>>>++++++++++>>>+++++++++++>>>++++++>>>+++++++>>>++>>>++++++>>>+++++++>>>+++++++>>>++>>>+++++++>>>++>>>+++++++++++>>>++++++++++>>>+++++++++++>>>+++++++>>>++>>>++++++>>>++++++++++>>>+>>>++++++++++>>>+++++++++++>>>++++++++>>>+>>>++>>>+++++++++>>>++++++>>>++++++>>>+++++++>>>+>>>++++++++++>>>+++++++++++>>>++++++>>>+++++++>>>++>>>+++++++>>>++>>>+++++++++++>>>++++++++++>>>+++++++++++>>>+++++++>>>++>>>+++++++++++>>>++++++++++>>>+++++++++++>>>++++++++++>>>++++++>>>+++++++>>>+>>>++++++++++>>>+++++++++++>>>++++++>>>+++++++>>>++>>>+++++++++++>>>++++++++++>>>+++++++++++>>>+>>>++++++>>>+++++++>>>++>>>++++++++++>>>++++++>>>++++++>>>++++++>>>++++++++>>>++++++>>>++++++>>>++++++>>>+++++++++>>>+++++++>>>+++++++>>>+++++++>>>++++++++>>>+++++++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++++>>>++++++>>>++++++++>>>++++>>>+++++++>>>+++++>>>+++>>>+++++>>>++++>>>+++++++>>>+++>>>++++++>>>++++++>>>+++++++++>>>+++++++>>>+++>>>+++++>>>++++++++>>>++++>>>+++++++++>>>+++++++>>>+++++++>>>+++++++++>>>++++++>>>++++++++>>>++++++>>>++++++>>>++++++>>>+++++++++>>>+++++++>>>+++++++>>>+++++++>>>++++++++>>>++++++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++++++>>>++++>>>++++++++>>>++++++>>>+++>>>+++++++>>>++++>>>++++++++>>>++++++>>>+++>>>+++>>>+++++++>>>++++>>>++++++++>>>++++++>>>+++>>>+++>>>+++++++>>>++++>>>++++++++>>>++++++>>>+++>>>+++++++>>>++++>>>++++++++>>>++++++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++++++>>>++++>>>++++++++>>>++++++>>>+++>>>+++>>>+++++++>>>++++>>>++++++++>>>++++++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++++++>>>++++>>>++++++++>>>++++++>>>+++>>>+++>>>+++++++>>>++++>>>++++++++>>>++++++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++++++>>>++++>>>++++++++>>>++++++>>>+++>>>+++>>>+++++++>>>++++>>>+++++++++>>>+++++++++>>>+++++++++>>>+++++++++>>>+++++++++>>>+++++++++>>>+++++++++>>>+++++++++>>>+++++++++>>>+++++++++>>>++++++>>>+++++>>>+++++++>>>+++++++>>>+++++++>>>+++++++>>>+++++++++>>>+++++++++++>>>++++++++++>>>+++++++++++>>>++++++>>>+++++++>>>{({}<>)<>}<>{([({})]()<((((()()()()()){}){}){})>){({}()<({}())>){({}()<({}()())>){({}()<({}()())>){({}()<({}())>){({}()<({}((()()()){}()){})>){({}()<({}()())>){({}()<({}(((()()()){}()){}){}())>){({}()<({}()())>){({}()<({}(((()()()()())){}{}){})>){(<{}({}()())>)}}}}}}}}}}{}({}<(<>)<>{({}<>)<>}{}>)(<><>)<>{({}<>)<>}{}<>{({}[()])<>(((((()()()){}())){}{}){}())<>}{}<>(((({})(((()()())){}{}){}())))<>}{}([]){((({}[()])<{({}[()]<({}<({}<>)<>>)>)}{}>)<{({}[()]<<>({}<>)>)}{}>)}{}{<>({}<>)}{}(<>){<<<[<<<]>>>[>++++++++++++++++++++++++++++++++++++++++.<[->.+.->+<<]>+.[-]>>]<[<<<]>>>[<++++++++++++++++++++++++++++++++++++++++>-[<+>-[<++>-[<++>-[<+>-[<++++++++++++++>-[<++>-[<+++++++++++++++++++++++++++++>-[<++>-[<++++++++++++++++++++++++++++++>-[<++>-]]]]]]]]]]<.>>>>]}{}<>

Experimente online!

Brain-Flak

(()()()()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()())(()()()()()()())(()())(()()()()()())(()()()()()()())(()()()()()()()()()()())(()()()()()())(()()()()()()())(()()()()()()()()()())(())(()()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(()())(()()()()()()()()())(())(()())(()()()()()())(())(())(())(())(())(()())(())(()())(())(()())(())(()())(())(()())(()())(()()()()()()()()()())(()()()()()()()()()()())(()())(()()()()()()()()()())(()()()()()()()()()()())(()())(()()()()()()()()()())(()()()()()()()()()()())(()())(()()()()()()())(()())(()()()()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(()())(()()()()()()())(()())(()()()()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(())(()())(()())(()()()()()()())(()())(()()()()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(())(()())(()())(()()()()()()())(()())(()()()()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(()())(()()()()()()())(()())(()()()()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(())(())(()())(())(()())(())(()())(()())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(()())(()()()()()()()()()())(()()()()()()()()()()())(()())(()()()()()()())(()())(()()()()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(())(()())(()())(()()()()()()())(()())(()()()()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(())(())(())(()())(())(()())(())(()())(()())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(()())(()()()()()()()()()())(()()()()()()()()()()())(()())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(()())(()()()()()()())(()())(()()()()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(())(()())(()())(()()()()()()())(()())(()()()()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(())(())(())(()())(())(()())(())(()())(())(()())(())(()())(()())(()())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()()()()()())(()()()()()()()()()()())(()())(()()()()()()()()()())(()()()()()()()()()()())(()())(()()()()()()())(()())(()()()()()()()()()())(())(()()()()()())(()()()()()()()()()())(()()()()()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(())(()())(()())(()()()()()()())(()())(()()()()()()()()()()())(()()()()()()()()()()())(()()()()()()()()()()())(()()()()()()()()()()())(()()()()()()()()()()())(()()()()()()()()()()())(()()()()()()()()()()())(()()()()()()()()()()())(()()()()()()()()()()())(()()()()()()()()()()())(()()()()()()()()()())(()()()()()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()())(())(()()()()()())(()()()()()()())(()())(()()()()()())(()()()()()()())(()()()()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()())(()()()()()()())(()())(()()()()()())(()()()()()()())(()()()()()()()()()()())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()()())(()())(())(()()()()()())(()()()()()()())(()()()()()())(()()()()()()())(()())(()()()()()())(()()()()()()())(()()()()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()())(()()()()()()())(()())(()()()()()())(()()()()()()())(()()()()()()()()()()())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()())(()()()()()()())(()()()()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()()()())(())(()())(()()()()()()()()())(()())(()()()()()())(()()()()()()())(())(())(())(())(())(())(()())(())(()())(())(()())(()())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(()())(()())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()()()()()())(()()()()()()()()()()())(()())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(()())(()()()()()())(()()()()()()())(()()()()()()()()()()())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()())(()()()()()()())(())(())(())(())(()()()()()()()()()())(()()()()()()()()()()())(()())(())(())(())(())(()())(())(()())(())(()())(()())(()())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()()()()()())(()()()()()()()()()()())(()())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(()())(()())(()())(()()()()()())(()()()()()()())(()()()()()()()()()()())(()()()()()()()()()())(()()()()()()()()()()())(())(()()()()()()()())(()()()()()()()()())(()())(()()()()()()()()()())(())(())(())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()()()())(())(()())(()()()()()()()()())(()())(()()()()()())(()()()()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()()()())(())(()())(()()()()()()()()())(()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()())(()()()()()()())(()())(()()()()()())(()()()()()()())(()()()()()()())(()())(()()()()()()())(()())(()()()()()()()()()()())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()()())(()())(()()()()()())(()()()()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()()()())(())(()())(()()()()()()()()())(()()()()()())(()()()()()())(()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()())(()()()()()()())(()())(()()()()()()())(()())(()()()()()()()()()()())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()()())(()())(()()()()()()()()()()())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()()()()()())(()()()()()())(()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()())(()()()()()()())(()())(()()()()()()()()()()())(()()()()()()()()()())(()()()()()()()()()()())(())(()()()()()())(()()()()()()())(()())(()()()()()()()()()())(()()()()()())(()()()()()())(()()()()()())(()()()()()()()())(()()()()()())(()()()()()())(()()()()()())(()()()()()()()()())(()()()()()()())(()()()()()()())(()()()()()()())(()()()()()()()())(()()()()()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()()()())(()()()()()())(()()()()()()()())(()()()())(()()()()()()())(()()()()())(()()())(()()()()())(()()()())(()()()()()()())(()()())(()()()()()())(()()()()()())(()()()()()()()()())(()()()()()()())(()()())(()()()()())(()()()()()()()())(()()()())(()()()()()()()()())(()()()()()()())(()()()()()()())(()()()()()()()()())(()()()()()())(()()()()()()()())(()()()()()())(()()()()()())(()()()()()())(()()()()()()()()())(()()()()()()())(()()()()()()())(()()()()()()())(()()()()()()()())(()()()()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()()()()()())(()()()())(()()()()()()()())(()()()()()())(()()())(()()()()()()())(()()()())(()()()()()()()())(()()()()()())(()()())(()()())(()()()()()()())(()()()())(()()()()()()()())(()()()()()())(()()())(()()())(()()()()()()())(()()()())(()()()()()()()())(()()()()()())(()()())(()()()()()()())(()()()())(()()()()()()()())(()()()()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()()()()()())(()()()())(()()()()()()()())(()()()()()())(()()())(()()())(()()()()()()())(()()()())(()()()()()()()())(()()()()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()()()()()())(()()()())(()()()()()()()())(()()()()()())(()()())(()()())(()()()()()()())(()()()())(()()()()()()()())(()()()()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()()()()()())(()()()())(()()()()()()()())(()()()()()())(()()())(()()())(()()()()()()())(()()()())(()()()()()()()()())(()()()()()()()()())(()()()()()()()()())(()()()()()()()()())(()()()()()()()()())(()()()()()()()()())(()()()()()()()()())(()()()()()()()()())(()()()()()()()()())(()()()()()()()()())(()()()()()())(()()()()())(()()()()()()())(()()()()()()())(()()()()()()())(()()()()()()())(()()()()()()()()())(()()()()()()()()()()())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()())(()()()()()()()){({}<>)<>}<>{([({})]()<((((()()()()()){}){}){})>){({}()<({}())>){({}()<({}()())>){({}()<({}()())>){({}()<({}())>){({}()<({}((()()()){}()){})>){({}()<({}()())>){({}()<({}(((()()()){}()){}){}())>){({}()<({}()())>){({}()<({}(((()()()()())){}{}){})>){(<{}({}()())>)}}}}}}}}}}{}({}<(<>)<>{({}<>)<>}{}>)(<><>)<>{({}<>)<>}{}<>{({}[()])<>(((((()()()){}())){}{}){}())<>}{}<>(((({})(((()()())){}{}){}())))<>}{}([]){((({}[()])<{({}[()]<({}<({}<>)<>>)>)}{}>)<{({}[()]<<>({}<>)>)}{}>)}{}{<>({}<>)}{}(<>){<<<[<<<]>>>[>++++++++++++++++++++++++++++++++++++++++.<[->.+.->+<<]>+.[-]>>]<[<<<]>>>[<++++++++++++++++++++++++++++++++++++++++>-[<+>-[<++>-[<++>-[<+>-[<++++++++++++++>-[<++>-[<+++++++++++++++++++++++++++++>-[<++>-[<++++++++++++++++++++++++++++++>-[<++>-]]]]]]]]]]<.>>>>]}{}<>

Experimente online!

O Brain-Flak pode expirar no TIO.

Explicação

Em breve.


Isso poliglota no final é bastante impressionante ...
ETHproductions

1
Explanation coming soon->Jan 27
MD XF

4

Ruby e Python (393 + 413 = 806 caracteres)

Ligeira mudança desta minha resposta . Definitivamente poderia ser reduzido, já que codifiquei a entrada sem nenhuma otimização.

Ruby (393 caracteres)

require 'json';s=%q[{"ruby":[" %q[","require 'json';s=##;j=JSON.load s;puts j[l='python'][1].sub('##',j[l][0].delete(' ')+s+j[l][2].delete(' '))"," ]"],"python":["' ''","import json,re;s=##;j=json.loads(s);l='ruby';print(re.sub('##',j[l][0].replace(' ','')+s+j[l][2].replace(' ',''),j[l][1],1))","' ''"]}];j=JSON.load s;puts j[l='python'][1].sub('##',j[l][0].delete(' ')+s+j[l][2].delete(' '))

Python (413 caracteres)

import json,re;s='''{"ruby":[" %q[","require 'json';s=##;j=JSON.load s;puts j[l='python'][1].sub('##',j[l][0].delete(' ')+s+j[l][2].delete(' '))"," ]"],"python":["' ''","import json,re;s=##;j=json.loads(s);l='ruby';print(re.sub('##',j[l][0].replace(' ','')+s+j[l][2].replace(' ',''),j[l][1],1))","' ''"]}''';j=json.loads(s);l='ruby';print(re.sub('##',j[l][0].replace(' ','')+s+j[l][2].replace(' ',''),j[l][1],1))

3

Python 2 a Befunge 98, 94 78

Mais uma vez, fazendo uso das duas maneiras de fazer strings do Python:

Python:

s='<@,kM%c%cs=%c%s%c;print s%%(39,34,39,s,39,34)%c';print s%(39,34,39,s,39,34)

Befunge 98:

<@,kM'"s='<@,kM%c%cs=%c%s%c;print s%%(39,34,39,s,39,34)%c';print s%(39,34,39,s,39,34)"

O programa python formata a string para incluir a si mesma e os caracteres para aspas simples e duplas.

O programa Befunge funciona assim:

  • <: mova para a esquerda e envolva. Então agora executamos os comandos da direita para a esquerda
  • ": faça com que todos os caracteres que encontrarmos sejam empurrados para a pilha até encontrarmos outro ", então pressionamos:

    )43,93,s,93,43,93(%s tnirp;'c%)43,93,s,93,43,93(%%s tnirp;c%s%c%=sc%c%Mk,@<'=s
    

    Na verdade, é apenas o programa python, revertido por causa da maneira como o Befunge imprime (que é um loop pop + print)

  • 'M: empurre Mpara a pilha. Mtambém é o número 77, que é um a menos que o número de caracteres enviados à pilha pelos "s.
  • k: retire o valor superior da pilha ( M) e execute a próxima operação várias vezes, mais uma.
  • ,: retire o valor superior da pilha e imprima o caracter.
  • @: finaliza o programa.

Que pena, e também em uma linguagem esotérica notoriamente difícil. Isso é ..... aterrorizante.
quer

2

Subcarga e Betaload , 16 bytes (não concorrente)

Sob carga:

(a(:^)*a(S)*S):^

Betaload:

((a(:^)*a(S)*S):^)S

Betaload é um superconjunto de Underload, portanto, podem ser duas respostas de Underload.

Isso não é competitivo porque o Betaload foi criado após o lançamento deste desafio.


1

Clipper e C (111 + 108 = 219 caracteres)

Tosquiadeira (111)

?'char*f="%c%cchar*f=%c%s%c;main(){printf(f,63,39,34,f,34,39,10);}%c%c";main(){printf(f,63,39,34,f,34,39,10);}'

C (108)

char*f="%c%cchar*f=%c%s%c;main(){printf(f,63,39,34,f,34,39,10);}%c%c";main(){printf(f,63,39,34,f,34,39,10);}

Isso é meio que um cop-out porque:

  1. o comando "print" no Clipper é realmente simples: ?'foo':-)
  2. Baseei-o no "clássico C" quine de http://www.nyx.net/~gthompso/quine.htm , com algumas modificações para espremer no ?e 's.
  3. Eu não fiz #include <stdio.h>, então ele dá um aviso do compilador
  4. A saída do código C pela versão Clipper teve que ser estimulada para remover uma quebra de linha introduzida por um limite de coluna de 80 caracteres no meu terminal ou na rotina de impressão Harbor ou algo assim.

Bem, o BASIC PRINTcomando pode ser abreviado ?bem :-)
Joey

0

Python e ~ - ~! - 77 e 81 = 158

Este código Python:

q=chr(124);s='@%sq=chr(124);s=%s;print(s%%repr(s))%s:';print(s%(q,repr(s),q))

gera isso ~ - ~! código:

@|q=chr(124);s='@%sq=chr(124);s=%s;print(s%%repr(s))%s:';print(s%(q,repr(s),q))|:

Definitivamente pode ser melhorado bastante e adota um monte de outras respostas.


0

Javascript e Windows .bat (71 e 81)

f=()=>{console.log('echo f='+(f+';f()').replace(/(?=[>^\\])/g,'^'))};f()

e

echo f=()=^>{console.log('echo f='+(f+';f()').replace(/(?=[^>^^^\^\])/g,'^^'))};f()
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.