niemand wird so wahnsinnig sein, dass er mit SPL an einer Code-Golf- Herausforderung teilnehmen kann, also ...
Meine eigenen Worte vor einer Weile. Und doch war jemand so wahnsinnig, es zu tun. Ja Ja ich weiss. Zu viele Bytes. Aber SPL verdient es, hier aufgenommen zu werden, denke ich. Und glauben Sie mir, ich habe eine gewaltige Anstrengung unternommen, um dieses Programm zu "golfen", weshalb es sich ein bisschen wiederholt und zumeist die gleichen Wörter verwendet (ich hätte immer dem Vorschlag von DLosc folgen können , aber das wäre selbst für mich zu extrem). .
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]
Was bedeutet das alles?
OK, wenn Sie neugierig sind, wie das alles funktionieren soll, lassen Sie mich versuchen, meine Argumentation zu erklären. Erstens die Variablen. Sie müssen aus shakesperianischen Stücken stammen, und da die Anzahl der Zeichen wichtig ist, müssen wir die kleinen auswählen. so Ajax
und Ford
erscheinen. Sie benötigen eine Beschreibung, nachdem sie deklariert wurden (was ignoriert wird, aber immer noch). Ich hätte einen einzigen Brief gebrauchen können, aber heh.
Akt I, Szene I
var Ajax, Ford;
Ford = 0;
Wir bringen die Variablen auf die Bühne und lassen Ajax
sagen, Ford
dass sein Wert 0 sein wird.
Akt I, Szene II
if (Ford > 2*1+1)
goto Scene V;
Ford = Ford + 1;
OK, wenn der in gespeicherte Wert Ford
größer als 3 ist, springt das Programm zu Szene V; Andernfalls wird der Wert inkrementiert.
Akt I, Szene 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;
Lasten und Lasten von Linien. Die Idee ist, mit dem gespeicherten Wert zu fummeln Ford
, viele arithmetische Operationen auszuführen, um die ASCII-Nummer der gewünschten Buchstaben zu erhalten, und dann den Compiler anzuweisen, die Nummer in Zeichenform auszugeben. So schreibst du Happy Birthday
. Es gibt eine if
innere Szene: Die Idee ist zu überprüfen, ob dies die dritte Phrase des Songs ist; wenn ja, springen wir zu Szene IV; ansonsten machen wir weiter, um zu schreiben to You
. Danach springen wir zurück zu Szene II.
Akt I, Szene 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;
Die Art und Weise, wie dies funktioniert, ähnelt der obigen Szene: Die Idee ist, zu schreiben Dear SPL
.
Akt I, Szene V
End.
Genau so.
Ich habe leider noch keinen Ort gefunden, an dem dies getestet werden kann ...