My timepass when SPOJ server was down!

Hey there!

I hope you enjoyed my last post about How I managed to download profile pictures of my facebook friends.

So, just like other normal days, when I am extremely into solving SPOJ problems one after another. And suddenly this happened!

There is a problem with SPOJ and their judge is down. Hence we are not able to process your submissions. We are looking into this.

CodeChef (@codechef) September 6, 2014



All of the websites based on SPOJ(CodeChef, Ideone etc.) were down consequently. I had just submitted my solution to a problem on SPOJ and I was yet to see the results of my submission. But it was down for long time enough to make me bore.

I was continuously refreshing the SPOJ website to know its status. Since, like all other programmers, I am also very lazy and believe in automating most of the boring tasks of life. I thought of automating this task as well!

Here is how I did it:

import requests
import winsound
from time import sleepcount=0
response = requests.get(‘ ‘)
if len(response.content) != 231:
print “Number of times checked: “+str(count)
print “Number of times checked: “+str(count)


This was the script that I wrote in just 15 minutes and automated the task of checking whether SPOJ website was up or not yet.

How does this work:

It keeps making HTTP requests to the SPOJ website and returns the response. Since SPOJ website wasn’t down on server so the HTTP request to website wasn’t returning any error code. So, it was really hard to detect whether site is up or not. So, what I did was – noted down the length of the return content when the website was down. It was just 231 chars down(which mainly included the html code for their error message). So using this number, I put a check on the number of chars in return content of HTTP call that whenever the number of chars in this response will be more than 231, it will make my system beep for the given number of seconds(milliseconds actually) once the website is UP.

Here is the Github Repo where I have committed the entire code that I used to serve this purpose. You can fork it and play around it as you want.

For feedback/suggestions/feature-requests, tweet me @sahildua2305 #SPOJtimepass


Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s