SPOJ — programming exercises

The Sphere Online Judge has thousands of programming exercises you can try (submit your code and see if it’s correct!) in lots of different languages. I’m only a (extremely) novice python programmer; here is my first submission to exercise 1 (code TEST):

#!/usr/bin/env python

n = 0
while n != 42:
    n = input()
    if n == 42:
        exit()
    print n

I think it’s a little ugly, with redundant bits of code. Maybe this could actually be done with around three lines rather than six? (Okay maybe not.)

Advertisements
  1. No trackbacks yet.

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: