javablogspot

Just another WordPress.com weblog

The 140 character webapp challenge

Posted by damuchinni on February 14, 2009

In Wikipedia you read:

In software engineering, a web application or webapp is an application that is accessed via web browser over a network such as the Internet or an intranet. It is also a computer software application that is coded in a browser-supported language (such as HTML, JavaScript, Java, etc.) and reliant on a common web browser to render the application executable.

So this is what I could come up with: just paste the following piece of code (140 characters) in a file with a .html extension, open it with a browser and you have a crude number guessing game:

<script>function
x(){if(confirm("odd?")&&((Math.floor(Math.random()*10))%2))alert(" ) ");else
alert(" ( ");if(confirm("rpt?"))x()}x()</script>

The browser calculates a random integer and asks you if it is an odd numbers. If your answer is correct it returns a smiley (or a frown if you’ve guessed wrong). Finally it asks you if you want to repeat the game and if you choose “ok” the whole thing starts over again.

You can save many characters by omitting the loop. Also you can save 10 whole characters by having the browser randomly choose “1” or “0” and asks you to guess between them.

<script>function x(){if(confirm(”1?”)&&(Math.round(Math.random())))alert(” ) “);else alert(” ( “);if(confirm(”rpt?”))x()}x()</script>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: