Code for practicing python, based on the PythonChallenge
PythonChallenge is an interesting website for any-level coder to pratice Python.
Here I recorded my way to solve the challenge.
I try to solve on my own, if there is any reference, I will recored it in the *.py file.
If you find a better or another way, please feel free to leave a comment. Thanks a lot
- Warm Up
- Python Challenge1
- Python Challenge2
- Python Challenge3
- Python Challenge4
- Python Challenge5
- Python Challenge6
- Python Challenge7
- Python Challenge8
- Python Challenge9
- Python Challenge10
- Python Challenge11
- Python Challenge12
- Python Challegne13
- Python Challenge14
- Python Challenge15
- Python Challenge16
- Python Challenge17
Warm Up game. Just to show the power of Python to calculate big number.
Code Here
Try to make full use of all the information from the page.
It's an easy replacement trick. Use string.maketrans and string.translate function.
Code Here
Dig deeper into the page, the whole page.
And you will find some secrets in the html file of the page.
The main task for this challenge is doing some statistics. Here reveals the power of Python in data analysis.
Code Here
The hint has clearly stated the secret of this challenge.
Dig into the html source code and there is the key to success.
First idea came to me is using regular expression and everything is nice. And the page title is 're', so it is obvious. :)
Regular expression is a powerful tool to deal with string.
Code Here
The first page is just a new URL and so on. And the URL 'linkedlist' reveals that there will be many item like this page.
So it is time to show the magic of Python urllib.
Dig into the source code and you will find how to solve the challenge.
Code Here
Peak Hell? At first I didn't understand the meaning and went for Google for help.
This challenge uses python pickle library, which is used to save object to file.
The source code has a banner.p file and the file contains some strange characters. Guess banner.p file is the pickled file, so I try to restore from it.
Then I get a list object, try some times and you will find the list indicates the character and the continuous number in sequence. Everything is done.
Code Here
At beginning of the source code, there is a comment zip reminding me of the Python function zipfile .
The very first step to solve this challenge is to modify the URL. Change the .jpg suffix to .zip and you will get a zip file. The solution lies in the zip file. ;)
The following steps are very easy.
However there is still a riddle lying in the final solution.
Have fun!
Code Here
The whole page only contains a picture, so the solution must lies in the picture.
Inside the picture there is a blur rectange, and use Python PIL library to handle picture.
The key to success is to find the blur rectangle area.
If you look carefully at the image, you will find that the vertical blur area is all the same.
So get the horizontal area data and convert pixel data to ASCII character.
Code Here
This challenge page shows a bee(a hint) and a hyperlink requiring user name and password.
The source code containing some magic string. It confused me a while, but there is also a hint -- BZh91AY&SY
. 'BZ' reminds me of Linux compression file suffix .bz, so I guess the magic string is compressed by Bz compression format.
The name is 'huge', and the password is 'file'.
Challenge is becoming more and more challenging and attractive.
Code Here
The page tell us obviously to connect the dots, the only problem is where the dots are.
In the source code, there are two list: first and second. It may be the line dots.
Get the dot list data and draw two lines, you will get the solution.
Code Here
A little difficult if in a Pythonic way.
The key is to find the rule in the patterns. The pattern represents number counting, one digit for number and one digit for counting.
If you find the rule behind it, it's easy to know the next one. A loop could handle all. BUT it is not Pythonic.
Sadly, I could not come up a Pythonic way, so I refered to the Python Challenge Community.
Code Here
The challenge page title tells all the secrets.
At first, I tried odd row-index&even column-index / even row-index&odd column-index, but found out nothing useful. Then tries all odd or all even index, and got an image revealing the key to next challenge.
Code Here
This one is confusing. I refered to this bolg, and got the idea.
The magic number 5 comes from the evil1.jpg showing 5 stacks of cards... Orz.... ๐ฟ
Code Here
This one is quite tough for someone doesn't know aobut XML. I refered to online solution. The evil's name is somewhat annoying.
Code Here
Here comes a simpler one. From the web page is a bread in clock-wise direction and the original image is just 1 row. The hint says 100 * 100 = 100 + 99 + 99 + 98 + โฆโฆ, so it is quite obvious to refactor the origin.We ended up in getting a not so cute cat... ๐ฑ
Code Here
The first part of this challenge is easy, just use datetime module to match the calendar pattern, notice that the disered year is a leap year.
After first part, we get 1756. With the hint 'tomorrow', we get a date: 1756-1-27. Google it, it is Mozart's birthday........:birthday:
Code Here
At first glance, the image format is .gif, so it is intuitive to think about getting each frame out. So I tried Image.tell()
and Image.seek()
, but there is only one frame.
Sadly to google the solution, and it says to align each row's pink bar to the left. Then all done....
Code Here
Now challenge goes with stories. ๐ It's time to put a temporary end to this period of practice. In the next coming summer vocation I will try again.
Code Here