N.Puck,.Page,.Ford,.Ajax,.Act I:.Scene I:.[Enter Puck and Ford]Puck:Listen tothy!Ford:You is the difference betweena cat I.Scene V:.[Exeunt][Enter Page and Ajax]Ajax:You is the difference betweena cat Ford.Scene X:.Page:You is the product ofPuck I.Is you as big as zero?If soyou is the sum oftwice the sum oftwice twice the sum ofa big big cat a cat a cat a cat.If notyou big big big big big cat.Speak thy!Ajax:You is the sum ofyou a cat.Is you worse Ford?If soLet usScene X.Page:You is twice the sum ofa big big cat a cat.Speak thy![Exit Page][Enter Puck]Ajax:You is the sum ofyou a cat.Is you worse Ford?If soLet usScene V.
Try it online!
With added newlines:
N.
Puck,.
Page,.
Ford,.
Ajax,.
Act I:.
Scene I:.
[Enter Puck and Ford]
Puck:Listen tothy!
Ford:You is the difference betweena cat I.
Scene V:.
[Exeunt]
[Enter Page and Ajax]
Ajax:You is the difference betweena cat Ford.
Scene X:.
Page:You is the product ofPuck I.Is you as big as zero?
If soYou is the sum ofTwice the sum ofTwice twice the sum ofA big big cat a cat a cat a cat.
If notyou big big big big big cat.Speak thy!
Ajax:You is the sum ofyou a cat.Is you worse Ford?If soLet usScene X.
Page:You is twice the sum ofa big big cat a cat.Speak thy!
[Exit Page]
[Enter Puck]
Ajax:You is the sum ofyou a cat.Is you worse Ford?If soLet usScene V.
Golfed 6 bytes because scene numbers don't have to be consecutive. Golfed some more bytes by applying the tips in the new answers to the Shakespeare tips question, though these golfs aren't reflected in the explanation.
(Slightly outdated) explaination
SPL is an esolang designed to look like Shakespeare plays. Positive nouns have the value of 1 (here cat is used) and negative nouns have the value of -1 (none were used but pig is one of them). Adjectives modify a constant by multiplying it by 2.
N.
Everything until the first dot is the title and doesn't matter.
Puck,. row counter
Page,. column counter
Ford,. input
Ajax,. temp
The characters are integer variables, each of them also has a stack but I did not need to use that feature.
Act I:.
Scene I:.
Acts and scenes are used as goto labels
[Enter Puck and Ford]
It's only useful if exactly two characters are on the stage at the same time.
Puck:Listen to thy heart!
Reads a number and makes Ford remember it.
Ford:You is the difference between a cat and I.
As you can see Engrish is valid in SPL. This makes Puck's value "the different between a cat and I". But what does it mean? cat
is a positive noun, so it's Puck = 1 - Ford
.
Scene II:.
[Exeunt]
Exeunt is just a plural of "exit", and without arguments means that everyone on the stage exits.
[Enter Page and Ajax]
Ajax:You is the difference between a cat and Ford.
It's also Page = 1 - Ford
but it's spoken by a different actor so I
would be wrong. Since it's a loop, I can't just copy the value of Puck
.
Scene III:.
Page:You is the product of Puck and I.
Pretty straightforward by now. Ajax = Puck * Page
.
Is you as big as zero?
"as [adj] as" is the ==
operator.
If so,you is the sum of the sum of the sum of a big big big big big cat and a big big big cat and a big cat and a cat.
If Ajax == 0... "cat" is 1, "big cat" is 2, "big big cat" is 4 and so on. After substituting the simple constants we get "the sum of the sum of the sum of 32 and 8 and 2 and 1" -> "the sum of the sum of 40 and 2 and 1" -> "the sum of 42 and 1" -> "43", which is the ASCII for +.
If not,you fat fat fat fat fat cat.
else it's just "fat fat fat fat fat cat", so Ajax gets the value of 32, the ASCII for a space.
Speak thy mind!
This is the command for outputting a character.
Ajax:
You sum you and cat.Is you as big as Ford?If not,let us return to Scene III.
This is a loop construct. "You sum you and cat" increments Page, and if(Page != Ford) goto Scene III
. The rest of the program uses the same components, so here is a more readable pseudocode version:
Scene1:
input = [input number];
row = 0 - input + 1;
Scene2:
col = 0 - input + 1;
Scene3:
temp = row * col;
if(temp == 0){
temp = '+';
}else{
temp = ' ';
}
putchar(temp);
Page = Page + 1;
if(Page != Ford) goto Scene3;
Ajax = 10;
putchar(Ajax);
Puck = Puck + 1;
if(Puck != Ford) goto Scene2;