Skip to content

Instantly share code, notes, and snippets.

@lufeihaidao
Created April 13, 2014 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lufeihaidao/10588651 to your computer and use it in GitHub Desktop.
Save lufeihaidao/10588651 to your computer and use it in GitHub Desktop.
Q6 of python challenge
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}/)
comment = entry.comment
output.push comment
end
puts output.join
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment