Tag Archives: Python challenge

Python Challenge Level 1

A couple of days back, I tried started solving questions from Python Challenge. In all there are 33 levels. I’ve completed the first few levels and I plan to blog about them. This is one is about how I solved the first level. Pull up a terminal and type, “python”. You get an interactive shell. Just type 2**38 and you get  the answer.

savita@Amrita:~/python_challenge$ python
Python 2.7.3 (default, Aug  1 2012, 05:16:07)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 2**38

Now following what the hint suggests, change the URL. The original URL is : http://www.pythonchallenge.com/pc/def/0.html . I tried changing that to : http://www.pythonchallenge.com/pc/def/274877906944L.html . As a result, I got this message : “the L in unnecessary”.  So I removed the L from the URL, and bingo !!! I got to the next level. This is the simplest way of doing it. You could even resort to scripting the command in a file and then executing the file. There are also ways of doing it.

Another way of solving this level is :

>>>pow(2, 38)

You could start too 🙂