Stringhe cicliche, programmi nascosti


13

Scrivi 3 programmi che svolgono la seguente attività:

Lasciate i codici sorgente A, B, C di questi tre programmi;

  • se A esegue BC viene prodotto come output,
  • se B esegue CA viene prodotto,
  • se C corre AB viene prodotto;

quindi ogni programma scrive una stringa (ciclicamente per ciascun programma) e si nasconde da essa.

Vincoli aggiuntivi, ma essenziali:

  • le scappatoie standard sono vietate;
  • ogni programma deve essere lungo almeno 1 byte;
  • ciascuno dei tre programmi deve essere scritto in una lingua diversa;

Sarebbe bello se la tua presentazione avesse questo formato:

Lingua A (dimensione di A) - Lingua B (dimensione di B) - Lingua C (dimensione di C) - Punteggio

A B C
<extra stuff>

Il vincitore è qualcuno che ottiene il punteggio minimo, che è la somma delle dimensioni di tre programmi.


Sarebbe più bello che il punteggio arrivasse per ultimo (per adattarsi alla sceneggiatura della classifica)
— Leaky Nun,


7
Non consiglierei le scadenze.
— Erik the Outgolfer,

Qualsiasi requisito circa A, Bed Cessendo diverse stringhe? Ad esempio, le tre stringhe possono essere uguali? Se il programma stampa una riga dopo l'output, non possiamo contarlo?
— Luis Mendo,

Non è necessario A, B, Cessere diversi. Le nuove righe vengono conteggiate come parte dell'output, quindi le nuove righe nella stringa fanno parte del programma.
— Blex,

Risposte:


3

Befunge-98 , Gol> <> e Wumpus 47 * 3 = 141 byte

"r75*1-47*0.@o&r84#o&]=74#]=\`/KHj '!_@#,k.'g00

Provalo in Befunge! Provalo in> <>! Provalo in Wumpus!

Esatto, è lo stesso programma tre volte! Se eseguito in una delle lingue sopra, stampa il codice sorgente due volte, ovvero gli altri due programmi concatenati.

Come funziona:

Befunge code:
  "r                               j '!_@#,k.'g00

  "   Wrapping string literal over code
   r  Reflect the pointer
  "   Wrapping string literal
                                              g00   Fetch " from cell 0,0 
                                          ,k.'      Print 47 characters
                                       _@#          If the next character is 0, exit
                                      !             Otherwise, set it to 0
                                   j '              And jump back to the beginning


Gol><> code:
  "r75*1-47*0.                \`/KH

  "             Wrapping string literal
   r            Reverse stack
    75*1-       Push "
         47*0.  Jump to cell 28,0
                              \  Continue right
                               `/K   Duplicate the top 47 characters on the stack
                                  H  Halt and output stack contents

Wumpus code:
  "r75*1-47*0.@o&r84#o&]=74#]=\

  "r75*1-47*0.  Exact same function as the ><> code, but with a bouncing string literal
                              \  Reflect left
                            ]=   Push a copy of the " to the bottom of the stack
                         74#     Push 47
                       ]=        Push a copy of the 47 to the bottom of the stack
                     o&          Print the top 47 characters
                  84#            Push a '0' to make up for the missing 0 at the end
               o&r               Reverse the stack and print the top 47 characters
              @                  And terminate

0

JScript, VBScript, Windows Batch, 345 byte

a=new ActiveXObject("scripting.filesystemobject");b=a.opentextfile(".js");c=b.readline();d=b.readline();a.createtextfile(".bat").write("@echo "+d.substr(2)+">.vbs\n@echo '"+c+">>.vbs")
//set a=createobject("scripting.filesystemobject"):set b=a.opentextfile(".vbs"):c=b.readline:d=b.readline:a.createtextfile(".js").write(mid(d,2)+chr(10)+"//"+c)

Denominare il file .js, quindi .vbs e quindi .bat verranno creati.

Utilizzando il nostro sito, riconosci di aver letto e compreso le nostre Informativa sui cookie e Informativa sulla privacy.
Licensed under cc by-sa 3.0 with attribution required.