- 浏览: 34422 次
- 性别:
最新评论
文章列表
#!/usr/bin/python -tt
The main() below is already defined and complete. It calls print_words()
and print_top() functions which you write.
1. For the --count flag, implement a print_words(filename) function that counts
how often each word appears in the text and prints:
word1 count1
word2 count2
... ...
#!/usr/bin/python -tt
# Basic string exercises
# Fill in the code for the functions below. main() is already set up
# to call the functions with a few different inputs,
# printing 'OK' when each function is correct.
# The starter code for each function includes a 'return'
# which is just a placehold ...
#!/usr/bin/python -tt
# D. Given a list of numbers, return a list where
# all adjacent == elements have been reduced to a single element,
# so [1, 2, 2, 3] returns [1, 2, 3]. You may create a new list or
# modify the passed in list.
def remove_adjacent(nums):
for num in nums:
if nums.index(nu ...
# A. match_ends
# Given a list of strings, return the count of the number of
# strings where the string length is 2 or more and the first
# and last chars of the string are the same.
# Note: python does not have a ++ operator, but += works.
def match_ends(words):
temp=0
for string in words:
i ...
absolutely lost...
reference:http://past.makto.me/post/2011-11-26/18573723
>>> import urllib
>>> web=urllib.urlopen('http://butter:fly@www.pythonchallenge.com/pc/hex/unreal.jpg')
>>> print web.info()
X-Powered-By: PHP/5.3.3-7+squeeze8
Content-Type: image/jpeg
Content-Range ...
After looking into the source code
some key words attracted me: 'encoding:base64' 'indian.wav'
another interesting hint is about the pic: the colours for the the mainland and ocean are exchanged
Note: I copied the 'indian.wav' on my laptop
my code below:
>>> import base64
>>> wf=op ...
the difference between these two images are brightness level, hence go to the 'brightness.html'
download 'delta.gz' and unzip the file
look into the dataset, the regular stuff would come out...
>>> import gzip
>>> f=gzip.open('/home/****/Downloads/deltas.gz')
>>> data=f.re ...
I spent much more time on this problem.
the information behind this pic:
1. the image from level4
2. lots of cookies
==> go into the corresponding cookies of level4 and you will find a hint:
'you+should+have+followed+busynothing...'
then repeat level 4 processes with the url (........./busynothin ...
This rule in my view is not so easy to figure out....
however, the code is generated depends on others' solution:
>>> data=[]
>>> image=Image.open('/home/****/Downloads/mozart.gif')
>>> for i in range(0,480):
data=[image.getpixel((j,i)) for j in range(0,640)]
for p in rang ...
what kinds of information can you remember for a calendar? year?date?month?weekdays?leapyear?... try to find these from the image
the code is:
>>> import calendar
>>> for year in range(1006,1997,10):
if calendar.monthrange(year,2)[1]==29:
temp=calendar.monthcalendar(year,1)
if temp[ ...
1. 100*100=(100+99+99+98)+(98+97+97+96)+...
2. the size of this image is 10000*1
3. the bread image tells some operation about rotation...
my thought is to draw the final image based on coordinateaxis
the implementation code:
>>> import Image
>>> image=Image.open('wire.png')
>&g ...
New stuff: xmlrpclib
#get the connection:
>>> from xmlrpclib import ServerProxy
>>> s=ServerProxy('http://www.pythonchallenge.com/pc/phonebook.php')
>>> s.system.listMethods()
['phone', 'system.listMethods', 'system.methodHelp', 'system.methodSignature', 'system.multicall', ...
For this issue,
firstly, I downloaded the image, then I found its name was 'evil1.jpg'
ps: it would be perfect if you hold kind of curiosity! lol... because you may want to try what will happen if you try the name 'evil2.jpg'....
finally, a file named 'evil2.gfx' was downloaded.
Next,I was absolutel ...
My initial thought was to find certain rules in the image dataset, but failed.
then I tried to divide the dataset into two groups based on the data position in the binary dataset, but the new image's size became a issue
the last idea also the solution: grouped the dataset into four types[(odd,odd),(e ...
At the beginning, I thought this would follow the rule: f(n+1)=f(n)+f(n-1)
It turned out to be wrong...
the damn look-and-say sequence....
the main problem is the implementation of this lovely algorithm:
I wrote the below code: (really bad but did work)
>>> a='1'
>>> for i in rang ...