This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bzip2' | |
un = "同上,需要用双引号括起来" | |
pw = "同上,需要用双引号括起来" | |
puts Bzip2.uncompress(un), Bzip2.uncompress(pw) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bz2 | |
un = "un 的字符串内容,表示 user name" | |
pw = "pw 的字符串内容,表示 password" | |
print bz2.decompress(un), bz2.decompress(pw) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "RMagick" | |
Magick::ImageList.new("oxygen.png").get_pixels(0,45,629,1).map.with_index | |
{|p,i| (p.red/255).chr if i%7==0)}.join.scan(/\d+/){|c| print c.to_i.chr } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re, Image | |
im = Image.open("oxygen.png") | |
row = [im.getpixel((x, 47)) for x in range(0, im.size[0], 7)] | |
chrs = [chr(r) for r, g, b, a in row if r == g == b] | |
s = ''.join(chrs) | |
print ''.join(map(chr, map(int, re.findall(r'\d+',s)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "zip/zip" | |
zipfilename = "/home/haidao/Downloads/channel.zip" | |
Zip::ZipFile.open(zipfilename) do |zipfile| | |
s = zipfile.get_input_stream("readme.txt").read | |
num = s.match(/\d{2,6}/) | |
output = Array.new | |
while num do | |
entry = zipfile.find_entry("#{num}.txt") | |
s = entry.get_input_stream.read | |
num = s.match(/\d{2,6}/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f = "channel.zip" | |
z = zipfile.ZipFile(f) | |
name = '90052.txt' | |
while 1: | |
print z.getinfo(name).comment, | |
name = z.read(name).split()[-1] + '.txt' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 推荐的做法 | |
import urllib2, sys, pickle | |
pickle_data = urllib2.urlopen('http://www.pythonchallenge.com/pc/def/banner.p').read() | |
data = pickle.loads(pickle_data) | |
for line in data: | |
for char, count in line: sys.stdout.write(char * count) | |
sys.stdout.write("\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ruby -wle 'n = 12345; print n = $1 while | |
`GET "http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=#{n}"` | |
=~ /(\d+)$/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "open-uri" | |
n=12345 | |
loop do | |
flag = '' | |
open("http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=#{n}") do |f| | |
s=f.read | |
flag = s if s=~/htm/ | |
n=(s=~/div/ ? n/2 : s.split[-1].to_i) | |
end | |
if !flag.empty? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
from urllib import urlopen | |
astring='http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=' | |
temp='12345' | |
f = urlopen(astring+temp) | |
a=f.read() | |
restring=re.compile('and the next nothing is (\d{3,5})') | |
for i in range(400): | |
temp=re.findall(restring,a)[0] | |
print(temp) |