Nota: esta resposta não pretende ser um concorrente sério
To Be or Not To Be, This is the Answer.
Hamlet, the main player in our story.
Horatio, Hamlet's guide through his internal struggles.
The Ghost, a handsome honest bold fair gentle king.
Claudius, the worthless usurper of the throne.
Ophelia, who Hamlet always writes two.
Polonius, the unfortunate third man caught between Hamlet and Claudius.
Brabantio, the greater.
Banquo, the lesser.
Emilia, the greater.
Egeus, the lesser.
Othello, the greater.
Orsino, the lesser.
Tybalt, the greater.
Titania, the lesser.
Valentine, who doubled is greater.
Viola, who doubled is lesser.
Act I: A simple question in so many words.
Scene I: Hamlet passes judgment over the cast.
[Enter Hamlet and Horatio]
Hamlet:
Thou art the sum of a good healthy sunny warrior and a lovely day.
[Exit Horatio]
[Enter Claudius]
Hamlet:
Thou art the sum of The Ghost and warm cute brave trustworthy hero.
[Exit Claudius]
[Enter Ophelia]
Hamlet:
Thou art the sum of Claudius and a smooth spaceman.
[Exit Ophelia]
[Enter Polonius]
Hamlet:
Thou art the sum of Ophelia and a plum.
[Exit Polonius]
[Enter Brabantio]
Hamlet:
Thou art the sum of The Ghost and the sum of The Ghost and a rich kingdom.
[Exit Brabantio]
[Enter Banquo]
Hamlet:
Thou art the sum of Brabantio and The Ghost.
[Exit Banquo]
[Enter Emilia]
Hamlet:
Thou art the sum of Brabantio and the sum of joy and a gentle girl.
[Exit Emilia]
[Enter Egeus]
Hamlet:
Thou art the sum of Emilia and The Ghost.
[Exit Egeus]
[Enter Othello]
Hamlet:
Thou art the sum of Emilia and the sum of a cunning lover and the sweetest golden embroidered rose.
[Exit Othello]
[Enter Orsino]
Hamlet:
Thou art the sum of Othello and The Ghost.
[Exit Orsino]
[Enter Tybalt]
Hamlet:
Thou art the sum of Othello and the sum of happiness and fair fine heaven.
[Exit Tybalt]
[Enter Titania]
Hamlet:
Thou art the sum of Tybalt and The Ghost.
[Exit Titania]
[Enter Valentine]
Hamlet:
Thou art the sum of Tybalt and the sum of a happy day and a pony.
[Exit Valentine]
[Enter Viola]
Hamlet:
Thou art the sum of Valentine and The Ghost.
[Exeunt]
Scene II: The beginning of Horatio's interrogation.
[Enter Hamlet and Horatio]
Hamlet:
Horatio:
Open your mind.
Art thou as good as Tybalt? If so, let us proceed to Scene IV.
Art thou as good as Titania? If so, let us proceed to Scene IV.
Art thou as good as Ophelia? If not, let us proceed to Scene XII.
Scene III: Are we to?
Horatio:
Open your mind.
Art thou as good as The Ghost? If so, let us proceed to Scene VII.
Let us proceed to Scene XII.
Scene IV: Can we go further than t?
Horatio:
Open your mind.
Art thou as good as Claudius? If so, let us proceed to Scene III.
Art thou as good as Valentine? If so, let us proceed to Scene VI.
Art thou as good as Viola? If so, let us proceed to Scene VI.
Art thou as good as Othello? If so, let us proceed to Scene V.
Art thou as good as Orsino? If not, let us proceed to Scene XII.
Scene V: Oone oor twoo?
Horatio:
Open your mind.
Art thou as good as The Ghost? If so, let us proceed to Scene VII.
Art thou as good as Othello? If so, let us proceed to Scene III.
Art thou as good as Orsino? If so, let us proceed to Scene III.
Let us proceed to Scene XII.
Scene VI: Hamlet desperately searches for whOo?.
Horatio:
Open your mind.
Art thou as good as Othello? If so, let us proceed to Scene III.
Art thou as good as Orsino? If so, let us proceed to Scene III.
Let us proceed to Scene XII.
Scene VII: Knowing to, what to do?
Horatio:
Open your mind.
Art thou as good as Brabantio? If so, let us proceed to Scene VIII.
Art thou as good as Banquo? If not, let us proceed to Scene XII.
Scene VIII: Learning what to Bleive.
Horatio:
Open your mind.
Art thou as good as me? If so, let us proceed to Scene XI.
Art thou as good as Emilia? If so, let us proceed to Scene X.
Art thou as good as Egeus? If so, let us proceed to Scene X.
Art thou as good as Polonius? If not, let us proceed to Scene XII.
Scene IX: The Eend is nigh?
Horatio:
Open your mind.
Art thou as good as me? If so, let us proceed to Scene XI.
Let us proceed to Scene XII.
Scene X: Wee may havee succeeeedeed.
Horatio:
Open your mind.
Art thou as good as Emilia? If so, let us proceed to Scene IX.
Art thou as good as Egeus? If so, let us proceed to Scene IX.
Art thou as good as me? If not, let us proceed to Scene XII.
Scene XI: Hamlet is at peace.
Horatio:
Thou art a beacon of happiness.
Let us proceed to Scene XIII
Scene XII: The demons have won.
Horatio:
Thou art nothing.
Scene XIII: Hamlet opens up.
Horatio:
Hamlet! Open your heart.
[Exeunt]
Emite 0 se falso, 1 se verdadeiro.
Isso poderia ser facilmente mais curto (e, se as pessoas realmente quiserem, o tamanho das palavras poderá ser reduzido), mas fazer isso seria um tapa na cara do bom e velho Will. Eu sempre senti que Horatio é o herói desconhecido de Hamlet, por isso me certifiquei de que ele fosse o responsável por entregar o monólogo intenso a Hamlet, onde Hamlet tem que provar que ele é tão bom quanto Horatio (que representa a nova linha).
O código em si é bem simples. Todos os caracteres sem Hamlet são valores ASCII (em ordem:) newline,space,0,2,3,B,b,E,e,O,o,T,t,V,v
e, em seguida, o código é uma máquina de estado simples (especificamente, um DFA ) que faz a transição para Scene XI
um estado de aceitação e Scene XII
um estado de rejeição.
.
Depois de fazer isso, apenas o pluguei em Shakespeare, usando o fato de que eu poderia descer para o próximo estado quando eles fossem numericamente adjacentes. Eu o testei apenas com a versão de Shakespeare que vinculei no título, mas acredito que definimos uma linguagem por meio de uma implementação iirc.