Jump to content
xisto Community
warbird1405241485

Prove Yourself As A Python Coder - Challenge Site

Recommended Posts

Recently I found a great site for python programmers. You have to find the url for the next level by solving a puzzle that requires Python (most other languages will also do quite well, but it's meant for python). The first levels you could do with some pen and paper or a calculator. But after a few puzzles they start to become more complicated and realy have to do more programming.

Tell us how far you have comes. The challenge has 33 levels, but I only beated the first 3. That doesn't say much since I'm a total newbie at Python.


-=jeroen=-


The link Python Challenge website

Edited by mastercomputers
Thought we could do with the link in the first post (see edit history)

Share this post


Link to post
Share on other sites

And how do you find the first URL ...oh wait ..u were so excited that u forgot to type it

Share this post


Link to post
Share on other sites

Hehe - he surely did. I can't find it either. Hey YOU, come back and put the url in for us... ;)

1064328228[/snapback]


"YOU" Has a name and that's warbird :P and YOU did forget the URL indeed, sorry for that. Here it is: http://www.pythonchallenge.com/.

 

-=jeroen=-

 

btw M^e: why did you edit my post?

Share this post


Link to post
Share on other sites

I'm going to repsond, since I think I know why (seeing as it looks like th eonly thing different, if I'm wrong m^e, yell at me and dedct 50% of my pay ;)). It looks like m^e changed your title to something more appropriate.~Viz

Share this post


Link to post
Share on other sites

Python does not seem to have a lot of activity so I thought I'll find something in here to do, and these python challenges seem to be right up my alley so I thought I'll try to explain and maybe spoil the challenges a bit.

 

I would just like to state first, that I am definitely no python guru as I had been discouraged by the attitudes of some python programmers who felt that because it existed in the standard library, there was no reason to "re-invent the wheel".

 

All I wanted to do while learning the language was try to create the same functions that already existed in these libraries but using what built-ins python provided. Maybe that's not the Pythonic way, but it's how I learn.

 

The first challenge is located at: http://www.pythonchallenge.com/pc/def/0.html

 

On opening it up with a web browser the title reads: "warming up".

 

On the page we are presented with a picture of a monitor. In the upper left corner of the monitor it has a 0 (zero), which makes me believe the challenges start from zero and works it's way up.

 

The screen of the monitor has a background of hills, trees, grass as well as a transparent wood coloured box with 2 exponent 38 (2 to the power of 38).

 

Below the picture is text with Hint: try to change the URL address.

 

OK, so the object is to try and change the URL address with 2 exponent 38. Looking at the URL, I guess we only have to change the 0 (zero) with the answer we get from 2 exponent 38, but there's not a lot to suggest that. The reason I'm describing a lot of the information, is to make sure I've read everything we are presented with. You don't want to miss any clues you are given.

 

So here's how I would write it in python.

 

Challenge 0

 

#!/usr/bin/env python

# -*- coding: utf-8 -*-

 

import webbrowser

 

site = 'http://www.pythonchallenge.com/pc/def/0.html'

 

webbrowser.open(site.replace('0', '%s' % 2**38))

 

 

 

Others may have their own solutions to solving these and it would be good to see how they go about it, as it's always good to learn new techniques or even better performing code.

Share this post


Link to post
Share on other sites

So we are onto the second challenge.

 

The title stating:

What about making trans?

. I believe everyone would need to have read and memorised the documentation for python, as it seems to be testing what we should know if we had read the docs.

 

I guess we can assume that the pictures will have the challenge number in the upper left corner, so no need to explain that unless it changes in the other challenges.

 

The image shows a binded notebook on a grey table cloth with blue leafy prints. Written on the Notebook are some letters and arrows,

K->M O->Q E->G

. This seems to be some sort of code, which has a pattern to it.

 

Below the picture is text that says:

everybody thinks twice before solving this.

. I'm not sure what this means, but I guess we do things twice before we can solve it.

 

There is also another set of text which seems to be jumbled text, possibly our code to decipher. As it is now:

g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj.

It's definitely some strange text. Also notice the

apostrophe

in this text, as storing it could cause some problems if you don't use

escaping

or the right

quotes

.

 

There also a list with some General tips which I don't feel ruins the challenge so I'll just list them:

 

Use the hints. They are helpful, most of the times.

Investigate the data given to you.

Avoid looking for spoilers.

Well, I seem to be ruining the last tip, but you should try to do these challenges yourself and in your own way/style.

 

So with the information I thought instead of doing 1 liners which is possible but throws readability out the door, I thought lets break it down, comment it and show how we can solve it working through the data we are given.

 

Challenge 1

 

#!/usr/bin/env python

# -*- coding: utf-8 -*-

 

"""http://www.pythonchallenge.com/pc/def/map.html;

 

import string

import re

import urllib2

import webbrowser

 

# grab the code to decipher from the page

code = re.search(re.compile('(?<=0\">)[^<]+'), urllib2.urlopen(__doc__).read()).group()

 

# reveal the hidden message

print code.translate(string.maketrans(string.ascii_lowercase, string.ascii_lowercase[2:] + 'ab'))

 

# apply it to the url and open it

webbrowser.open(__doc__.replace('map', 'map'.translate(string.maketrans(string.ascii_lowercase, string.ascii_lowercase[2:] + 'ab'))))

 

 

 

At least I made use of the clues provided, which I guess is the whole idea to these challenges, however sometimes the clues aren't that helpful, or the best way to do things. As with the other solutions, if you can provide your own methods, etc it would be good.

 

I know with my above code, it can be improved, but there are multiple solutions to them and for me, solving them no matter what is what these challenges should be about, no matter if it's not the best. You can always improve your code further down the track, just try and not get caught into bad habits.

 

 

Cheers,

 

 

MC

Share this post


Link to post
Share on other sites

Seriously, if you ask me it is hard to solve some of the puzzle. most of time you don't get it the way to type answers in the URL. i got stuck over there. maybe i'm not good into programming or didn't get it ? whatever.

Share this post


Link to post
Share on other sites

We are now on the third challenge.

 

The title is

ocr

. This is an acronym for

optical character recognition

so I believe the task is to

recognise characters

 

 

Again with most of these challenges there is a picture and a hint below it.

 

This picture is of an

opened book between two pillows, the page it is opened on, is very blurry and hard to read

 

 

The hint suggests:

recognize the characters. maybe they are in the book, but MAYBE they are in the page source.

 

 

So this hint suggests we should be looking elsewhere. So on viewing the

page source

I notice another hint:

find rare characters in the mess below:

and below it is

a comment containing a lot of printable characters

 

 

This seems to be quite a testing challenge, and the clues are very vague. Maybe we will try as much of the clues to do as possible for this code.

 

Challenge 2

 

#!/usr/bin/env python

# -*- encoding: utf-8 -*-

 

"""http://www.pythonchallenge.com/pc/def/ocr.html;

 

import re

import urllib2

import webbrowser

 

#grab the mess from the page source

mess = re.findall(re.compile('(?<=!--)[^--]+'), urllib2.urlopen(__doc__).read())[1]

 

#count the characters in the mess

char_count = {}

for char in mess:

char_count[char] = char_count.get(char, 0) + 1

 

#get the rares and open the page

webbrowser.open(__doc__.replace('ocr', '%s' % (''.join(char for char in mess if char_count[char] == 1))))

 

 

 

If I wasn't too concern about spoiling the challenges, I would explain my steps a lot better.

 

 

Cheers,

 

 

MC

Share this post


Link to post
Share on other sites

Hey starscream,You are right about it being hard, as they don't give you clues to how to answer it properly and I do hate assumption at times, but sometimes it's the only logical choice you can make.Just because you cannot pass the challenges, does not mean you're not a good programmer. Myself I don't consider myself a Python programmer, I know the language but not like other languages which I've had years more experience with. I usually rely on what knowledge I have from other languages and try to work the same way from those languages, even if it's not the efficient way for Python. There would be some python programmers who haven't completed these challenges, yet they are capable of creating great work in the python field.These challenges are just testing what you know. You can always return back later and try again and see if you've furthered your learning. For me, posting my solutions here so I can refer back to them later, so that if I learn something new that makes the code better, I can come back and post an alternative solution that would be better and help others benefit more.However, my amusement for these challenges seems to go after doing the first few. As in my posts, I am wanting to explain my code but feel it's not right if I spoil the challenges for others. They will only spoil it themselves if they look at my spoilers.Cheers,MC

Share this post


Link to post
Share on other sites

ah thanks for reply MC. I too feel that such puzzles and all are not always test what we know or could do. but those are good for mind exercise. didn't gone through spoilers cause i wanted to attempt them myself, that is one thrill.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.