Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411508 Posts in 69374 Topics- by 58429 Members - Latest Member: Alternalo

April 26, 2024, 08:34:06 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Coding Challenge 2: Shakespeare
Pages: [1]
Print
Author Topic: Coding Challenge 2: Shakespeare  (Read 6249 times)
Terry
TIGSource Editor
Level 10
******



View Profile WWW
« on: July 20, 2008, 01:15:43 PM »

Time for our second challenge - Write any functional program in Shakespeare!

Shakespeare is a brainfuck-like programming language by Kalle Hasselström and Jon Åslund. It translates scripts that resemble Shakespeare plays into C code. As an example, here's what Hello World looks like:

Quote
The Infamous Hello World Program.

Romeo, a young man with a remarkable patience.
Juliet, a likewise young woman of remarkable grace.
Ophelia, a remarkable woman much in dispute with Hamlet.
Hamlet, the flatterer of Andersen Insulting A/S.


                    Act I: Hamlet's insults and flattery.

                    Scene I: The insulting of Romeo.

[Enter Hamlet and Romeo]

Hamlet:
 You lying stupid fatherless big smelly half-witted coward!
 You are as stupid as the difference between a handsome rich brave
 hero and thyself! Speak your mind!

 You are as brave as the sum of your fat little stuffed misused dusty
 old rotten codpiece and a beautiful fair warm peaceful sunny summer's
 day. You are as healthy as the difference between the sum of the
 sweetest reddest rose and my father and yourself! Speak your mind!

 You are as cowardly as the sum of yourself and the difference
 between a big mighty proud kingdom and a horse. Speak your mind.

 Speak your mind!

[Exit Romeo]

                    Scene II: The praising of Juliet.

[Enter Juliet]

Hamlet:
 Thou art as sweet as the sum of the sum of Romeo and his horse and his
 black cat! Speak thy mind!

[Exit Juliet]

                    Scene III: The praising of Ophelia.

[Enter Ophelia]

Hamlet:
 Thou art as lovely as the product of a large rural town and my amazing
 bottomless embroidered purse. Speak thy mind!

 Thou art as loving as the product of the bluest clearest sweetest sky
 and the sum of a squirrel and a white horse. Thou art as beautiful as
 the difference between Juliet and thyself. Speak thy mind!

[Exeunt Ophelia and Hamlet]


                    Act II: Behind Hamlet's back.

                    Scene I: Romeo and Juliet's conversation.

[Enter Romeo and Juliet]

Romeo:
 Speak your mind. You are as worried as the sum of yourself and the
 difference between my small smooth hamster and my nose. Speak your
 mind!

Juliet:
 Speak YOUR mind! You are as bad as Hamlet! You are as small as the
 difference between the square of the difference between my little pony
 and your big hairy hound and the cube of your sorry little
 codpiece. Speak your mind!

[Exit Romeo]

                    Scene II: Juliet and Ophelia's conversation.

[Enter Ophelia]

Juliet:
 Thou art as good as the quotient between Romeo and the sum of a small
 furry animal and a leech. Speak your mind!

Ophelia:
 Thou art as disgusting as the quotient between Romeo and twice the
 difference between a mistletoe and an oozing infected blister! Speak
 your mind!

[Exeunt]

You can find instructions on how it works here, and some details on how to actually go about writing something in it here. Best of luck!
Logged

Terry
TIGSource Editor
Level 10
******



View Profile WWW
« Reply #1 on: July 20, 2008, 01:22:22 PM »

By the way, if that's a bit overwhelming, here's a much simpler example which adds two numbers together:

Quote
A simple program to add two values.

Romeo, A character to store the sum.
Juliet, An admirer who helps to calculate the sum.

      Act I: A simple play.

   Scene I: Juliet's conversation with Romeo.

[Enter Romeo and Juliet]

Juliet: Listen to your heart!

Romeo:  You are as beautiful as a sweet red rose.
   Listen to your heart.

Juliet: You are as brave as the sum of me and thyself.
   Open your heart!

[Exeunt]

"Romeo" and "Juliet" are variables. When Juliet says "Listen to your heart", that asks for user input to store a value in Romeo. When Romeo says "You are as beautiful as a sweet red rose", that stores the value 4 in Juliet (sweet=adjective, so multiply by two, red + rose = 2, so 4 in total). Juliet's last line "You are as brave as the sum of me and thyself. Open your heart!" adds the values of Romeo and Juliet together and displays it.
Logged

Cheater‽
Level 10
*****



View Profile
« Reply #2 on: July 20, 2008, 02:44:25 PM »

 Shocked
Logged
Terry
TIGSource Editor
Level 10
******



View Profile WWW
« Reply #3 on: July 20, 2008, 03:12:01 PM »

Don't be scared Smiley It's all very logical really!
Logged

Pacian
Text Heavy
Level 4
*



View Profile WWW
« Reply #4 on: July 20, 2008, 04:05:44 PM »

Do you bite your thumb at us, sir?  Shocked
Logged

(\ /)
(O.o) - Achtung, baby!
(> <)
Akhel
Level 10
*****



View Profile
« Reply #5 on: July 20, 2008, 04:27:55 PM »

It is very important that someone writes a LOLCODE compiler in this.
Logged
Noyb
Level 9
****



View Profile WWW
« Reply #6 on: July 20, 2008, 07:13:08 PM »

Jeez, you'd think that a programming language based on the Bard's works would have more string manipulation tools than that. Declaring constants bit-by-bit based on the number of adjectives before a noun is both absolutely insane and hilariously poetic, leading to that crazy long "Hello World" program which prints out the phrase one letter at a time. Might be fun to try something if I have some free time this week.

Also:
Quote
Juliet: You are as villainous as the square root of Romeo!
Logged

Hideous
That's cool.
Level 10
*****


3D models are the best


View Profile WWW
« Reply #7 on: July 21, 2008, 07:12:00 AM »

Ohohoho. Fuck you :D
Logged

andy wolff
Level 10
*****


-------


View Profile
« Reply #8 on: July 21, 2008, 08:31:28 AM »

terry==iago. curse thine vile heart, yon villain.
Logged

Jrsquee
Guest
« Reply #9 on: July 22, 2008, 06:20:59 PM »

It is very important that someone writes a LOLCODE compiler in this.

I agree.  VERY IMPORTANT INDEED
Logged
Decipher
Guest
« Reply #10 on: July 23, 2008, 07:27:39 AM »

Okay, so I'm not really familiar with the Shakespeare's language dynamics. Thus I couldn't really study the optimum way to do something using the language, though I should mention anyone with a crumb of an assembly experience should be capable of pulling out something.

I was trying to do something but the lack of capability of the language made me change the stuff I work on this morning. So, the coe below is totally hacked today during a work-break, and I didn't really test it, so no guarantee it will work.

It calculates the Adler-32 CRC checksum of an input string. But it's not 100% Adler-32 compliant as the language lacks bitwise operations and I had no time to code them using integer arithmetic. And, the language also lacks modulo functionality thus the output might be misleading for longer strings.

Since there are no bitwise operations the output is the final operation you must perform to get the CRC. The form of the output must be of the following syntax:
Code:
X|Y where X and Y are unsigned integers and | stands for bitwise-or.

So, there you go. View with an editor that supports 4-character width tabs.

Code:
							   Sapor, Quod Ego Es
An exigence of amour in memorum of the beneficent, He are of perpetual grandeur.

Hamlet,  a nobleman of a glorious but yet intense etude, shall I be his creator.
Malcolm, for he is the humble servant of Me existence.
Macbeth, that who corrupts his inhumane being as I are the ill-wisher for him.
Duncan,  royal as he is a king, although a king shall not exist for I reign.

Act I: Genesis in Vivo
Scene I: Shall I proceed?
[Exeunt]
[Enter Hamlet Macbeth]

Macbeth:
Listen to your heart!

Hamlet:
Am I as good as the difference between a rich wealthy beautiful little
princess and the sum of a nice flower and a tree?

Macbeth:
If so, we shall proceed to scene III.

[Exit Hamlet]
[Enter Duncan]

Duncan:
Thou art as adorable as the sum of Hamlet and thyself.

[Exit Macbeth]

Scene II: I are of ruthless obfuscation!
[Enter Malcolm]

Malcolm:
Thou art as well as the sum of Macbeth and thyself. Thou art as majestic as
the sum of a king and thyself.

[Exit Duncan]

Malcolm:
We shall proceed to Scene I.

  Scene III: Even the roses shall die!
[Enter Hamlet Malcolm]

Hamlet:
Thou art as promicious as the product of a wonderful niche favourable elegant
special interesting peculiar woeful humble young joyful royal humane gentle
adorable noble pony and Duncan. Open your heart!

Hamlet:
Thou art as precious as the difference between a nice heroic brave powerful
strong dominant invaluable prince and a tree. Speak your mind!

Hamlet:
Thou art as shameful as Macbeth! Open your heart!

Hamlet:
Thou art as glorious as the sum of a wonderful tasteful red apple and a
little rabbit. Speak your mind!
« Last Edit: July 23, 2008, 07:32:44 AM by Decipher » Logged
george
Level 7
**



View Profile
« Reply #11 on: July 23, 2008, 04:31:33 PM »

Quote
Thou art as promicious as the product of a wonderful niche favourable elegant special interesting peculiar woeful humble young joyful royal humane gentle adorable noble pony and Duncan


Bravo!
Logged
Decipher
Guest
« Reply #12 on: July 23, 2008, 08:36:43 PM »

:D it's quite frustrating to express 2**16
Logged
Terry
TIGSource Editor
Level 10
******



View Profile WWW
« Reply #13 on: July 27, 2008, 02:21:01 PM »

Congrats Decipher Smiley

So, has anyone actually been able to get this to work? I was going to write something tonight, but the frontend apparently links to a corrupt file and I can't get the download on the main site to compile :O Sorry. Guess I should have tested that sorta thing before I posted the challenge...

There doesn't appear to be that much interest in this one anyway... let's move on Smiley
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic