nessuno sarà abbastanza demenziale per partecipare a una sfida di code-golf con SPL, quindi ...
Le mie stesse parole, qualche tempo fa. Eppure, qualcuno è stato demente abbastanza per farlo. Si si lo so. Troppi byte. Ma SPL merita di essere incluso qui, credo. E credimi , ho fatto uno sforzo gigantesco per "giocare a golf" questo programma, motivo per cui è un po 'ripetitivo e usa principalmente le stesse parole (avrei sempre potuto seguire il suggerimento di DLosc , ma sarebbe troppo estremo anche per me) .
A Happy Birth Day
Ajax, a hero
Ford, a man
Act I: 1
Scene I: 1
[Enter Ajax and Ford]
Ajax:
You are nothing!
Scene II: 2
Ford:
Am I nicer than the sum of a big cow and a son?
Ajax:
If so, we shall go to Scene V. You are as big as the sum of thyself and a cat!
Scene III: 3
Ford:
You are as red as the sum of a big red warm rich bold fair cat and a big rich fine son.
Speak thy mind! You are as big as the sum of thyself and the sum of a cute fair fine
rich cat and a hog! Speak thy mind! You are as big as the sum of thyself and the sum
of a cute fair fine rich cat and a hog. Speak thy mind. Speak thy mind! You are as bold as
the sum of thyself and the sum of a big fine fair cat and a cow. Speak thy mind! You are
as big as a red old fair fine tiny cow. Speak thy mind! You are as old as the sum of
thyself and the sum of a red old fair fine tiny cow and a big joy. Speak thy mind.
You are as red as the sum of thyself and the sum of the sum of a red old fair fine
tiny cow and a rich old red sky and a pig. Speak thy mind! You are as old as the sum
of thyself and the sum of a big fine fair joy and a son. Speak thy mind. You are as
red as the sum of thyself and a cute son. Speak thy mind! You are as cute as the sum
of thyself and the sum of a bad fat vile pig and a fat bad lie. Speak thy mind! You are
as fat as the sum of thyself and a vile evil war. Speak thy mind! You are as vile as the
sum of thyself and the sum of a pig and a toad. Speak thy mind! You are as fair as the
sum of thyself and the sum of a big fair hard fine son and a red fine fair joy. Speak
thy mind! Are you as old as a big cow?
Ajax:
If so, we shall go to Scene IV.
Ford:
You are as big as a red old fair fine tiny cow. Speak thy mind! You are as old as the sum
of thyself and the sum of the sum of a big red warm rich bold fair cat and a red old fair
fine tiny cow and a bad hog. Speak thy mind! You are as big as the sum of thyself and the
sum of a fat bad hog and a war. Speak thy mind! You are as big as a red old fair fine tiny
cow. Speak thy mind! You are as old as the sum of thyself and the sum of a big red warm
rich bold fair cat and a fat foul bad hog and a son. Speak thy mind. You are as fat as
the sum of thyself and the sum of the sum of a big fair hard fine son and a big fine
fair joy and a bad pig. Speak thy mind.
Ajax:
Let us return to Scene II.
Scene IV: 4
Ford:
You are as big as a red old fair fine tiny cow. Speak thy mind! You are as old as the
sum of thyself and a big red warm rich bold fair cat and a warm sky. Speak thy mind.
You are as fat as the sum of thyself and the sum of a red old fair fine tiny cow and a
cat. Speak thy mind. You are as fat as the sum of thyself and a bad foul hog. Speak
thy mind. You are as cute as the sum of thyself and the sum of a big fair hard fine
son and a sky. Speak thy mind. You are as big as a red old fair fine tiny cow. Speak thy
mind! You are as old as the sum of thyself and the sum of thyself and the sum of the sum
of the sum of a red old fair fine tiny cow and a big fair hard fine son and a big joy and
a son. Speak thy mind. You are as bad as the sum of thyself and the sum of a fat pig and a
hog. Speak thy mind. You are as fat as the sum of thyself and a lazy pig. Speak thy mind.
Ajax:
Let us return to Scene II.
Scene V: 5
[Exeunt]
Il significato di tutto questo?
OK, se sei curioso di sapere come dovrebbe funzionare tutto ciò, lasciami provare a spiegare il mio ragionamento. Innanzitutto, le variabili. Devono provenire da commedie shakesperiane e, poiché il conteggio dei caratteri è importante, dobbiamo scegliere quelli piccoli; così, Ajax
eFord
apparire. Hanno bisogno di una descrizione dopo essere stati dichiarati (che è ignorato, ma comunque); Avrei potuto usare una sola lettera, ma eh.
Atto I, scena I
var Ajax, Ford;
Ford = 0;
Portiamo le variabili sul palco e facciamo Ajax
capire Ford
che il suo valore sarà 0.
Atto I, scena II
if (Ford > 2*1+1)
goto Scene V;
Ford = Ford + 1;
OK, se il valore memorizzato Ford
è maggiore di 3, il programma passa alla scena V; altrimenti, il suo valore viene incrementato.
Atto I, scena III
Ford = 2*2*2*2*2*2*1+2*2*2*1;
print((char) Ford);
Ford = Ford+2*2*2*2*1-1;
print((char) Ford);
Ford = Ford+2*2*2*2*1-1;
print((char) Ford);
print((char) Ford);
Ford = Ford+2*2*2*1+1;
print((char) Ford);
Ford = 2*2*2*2*2*1;
print((char) Ford);
Ford = Ford+2*2*2*2*2*1+2*2*2*1+(-1);
print((char) Ford);
Ford = Ford+2*2*2*1+1;
print((char) Ford);
Ford = Ford+2*1;
print((char) Ford);
Ford = Ford+2*2*2*(-1)+2*2*(-1);
print((char) Ford);
Ford = Ford+2*2*(-1);
print((char) Ford);
Ford = Ford+2*(-1)+(-1);
print((char) Ford);
Ford = Ford+2*2*2*2*1+2*2*2*1;
print((char) Ford);
if (Ajax == 2*1)
goto Scene IV;
Ford = 2*2*2*2*2*1;
print((char) Ford);
Ford = Ford+2*2*2*2*2*2*1+2*2*2*2*2*1+2*(-1);
print((char) Ford);
Ford = Ford+2*2*(-1)+(-1);
print((char) Ford);
Ford = 2*2*2*2*2*1;
print((char) Ford);
Ford = Ford+2*2*2*2*2*2*1+2*2*2*(-1)+1;
print((char) Ford);
Ford = Ford+2*2*2*2*1+2*2*2*1+2*(-1);
print((char) Ford);
Ford = Ford+2*2*2*1+2*-1;
print((char) Ford);
goto Scene II;
Carichi e carichi di linee. L'idea è quella di giocherellare con il valore archiviato Ford
, facendo un sacco di operazioni aritmetiche al fine di ottenere il numero ASCII delle lettere desiderate, quindi diciamo al compilatore di produrre il numero in forma di carattere. È così che scrivi Happy Birthday
. C'e 'unif
dentro scena: l'idea è di verificare se questa è la terza frase della canzone; se lo è, passiamo alla scena IV; altrimenti continuiamo a scrivereto You
. Dopodiché, torniamo alla scena II.
Atto I, scena IV
Ford = 2*2*2*2*2*1;
print((char) Ford);
Ford = Ford+2*2*2*2*2*2*1+2*2*1;
print((char) Ford);
Ford = Ford+2*2*2*2*2*1+1;
print((char) Ford);
Ford = Ford+2*2*(-1);
print((char) Ford);
Ford = Ford+2*2*2*2*1+1;
print((char) Ford);
Ford = 2*2*2*2*2*1;
print((char) Ford);
Ford = Ford+2*2*2*2*2*1+2*2*2*2*1+2*1+1;
print((char) Ford);
Ford = Ford+2*(-1)+(-1);
print((char) Ford);
Ford = Ford+2*2*(-1);
print((char) Ford);
goto Scene II;
Il modo in cui funziona è simile alla scena sopra: l'idea è quella di scrivere Dear SPL
.
Atto I, scena V
End.
Proprio così.
Non ho ancora trovato un posto dove questo può essere testato, sfortunatamente ...