views:

1447

answers:

10

I was watching one of those incredibly retarded tv quiz money scams last night as I was reading reddit and they posed the question:

if you wrote down all the numbers between 32 to 287 how may times would you write down the number 6?

So I did some quick maths in my head (there are 11 sixes in each 100, there are two hundreds in between the two numbers and then there are six more = 22 + 6 = 28). The first caller rings up and says 28.

I am not great at maths in my head but I could think of a pretty easy for loop that would figure it out, but there is no way I was going to go through the hassle of installing an IDE on my home machine just to write five lines of code. My question:

Is there a website where I can write simple algorithms like this and compile them and get results all in-browser without having to install any crap or jump through any hoops?

A: 

There's an online "live demo" for the LUA language here: http://www.lua.org/demo.html

Ron
+1  A: 

This answer is going to be language specific. For the best answer, javascript would work well. Since it already runs in the browser, writing an interpreter that runs in the browser is a piece of cake. Just google for "javascript interpreter" and you'll get a bunch of hits.

swampsjohn
+4  A: 

There is also web based interpreters for Python:

http://try-python.mired.org/

And for Ruby:

http://tryruby.hobix.com/

Example for the Python online interpreter:

Python 2.5.2 (r252:60911, May 29 2008, 09:50:36) [C] on sunos5
Type "help", "copyright", "credits", or "license" for more information.
>>> total=0
>>> for a in range(32,288):
...    total = total + str(a).count('6')
... 
>>> total
56
Andre Miller
The reason range(32,288) was used is because the built-in Python range() function returns a list of integers one less than the stop argument. Not that it would make a difference here of course, 287 contains no sixes :)
Andre Miller
A: 

There is an online Ruby interpreter at: http://tryruby.hobix.com/

It has a pretty good tutorial too to help you learn Ruby as you go.

Paul Bullough
+1  A: 

If you can write the algorithms in Javascript, use Project Bespin.

Bespin is a Mozilla Labs experiment that proposes an open, extensible web-based framework for code editing that aims to increase developer productivity, enable compelling user experiences, and promote the use of open standards.

Robert Munteanu
A: 

There's a whole bunch of BASIC emulators!

http://www.vavasour.ca/jeff/level1/simulator.html

Great for some instant

10 PRINT "HELLO"
20 GOTO 10
Robin Day
+4  A: 

A quick google found http://www.coderun.com/. It apparently supports .NET, PHP and AJAX.

EDIT:

Supports IE7 and Firefox (i.e. none of the browsers installed on my current machine)

Patrick McDonald
+3  A: 

Code Pad supports a lot of programming languages, is free and doesn't require registration.

Niki Yoshiuchi
A: 

The best online tool I've found (except for codepad) is http://jsfiddle.net/

You are able to write the HTML, CSS and JavaScript for your app. You can choose from 10 JavaScript frameworks (I recommend jQuery for simple tests). And to test you only need to press the Run buttons. Allows for online saving (pastebin-like), which is also good.

eddyb
A: 

Nowadays there's also the ideone.com. It supports a large variety of programming languages, including esoteric ones.

BalusC