PythonChallenge第6题

来源:互联网 发布:c语言预处理指令应用 编辑:程序博客网 时间:2024/05/21 22:02

点击题目链接

进去一个图片还很邪恶的图片,让我捐款。。。
查看网页代码,还真让我捐款,但是上面发现了 <– zip –>
进入:http://www.pythonchallenge.com/pc/def/zip.html,页面是:yes. find the zip.这就对了。
http://www.pythonchallenge.com/pc/def/zip 不对
http://www.pythonchallenge.com/pc/def/channel.html/zip 不对
http://www.pythonchallenge.com/pc/def/channel.zip对了,下载zip文件

里面910个txt文件。。。
有个readme
welcome to my zipped list.

hint1: start from 90052
hint2: answer is inside the zip
题目类似上面一个题目的nothing 找id
OK

package PythonChallenge;import java.io.BufferedReader;import java.io.File;import java.io.FileNotFoundException;import java.io.FileReader;import java.io.IOException;class Level06{    Level06(){        String Filename="channel\\";        String FirstFilename=Filename+"90052.txt";        int i=0;        while(i<909){            String str=MyFileReader(FirstFilename);            if(findFirstNumIndex(str)!=-1){            String nextNum=str.substring(findFirstNumIndex(str),findLastNumIndex(str)+1);            FirstFilename=Filename+nextNum +".txt";            i++;            }else{                System.out.println(FirstFilename);                break;            }        }        System.out.println(MyFileReader(FirstFilename));}    int findFirstNumIndex(String str){        char[] strArray=str.toCharArray();        int i;        for( i=0;i<strArray.length;++i){            if(strArray[i]>='0' && strArray[i]<='9'){                break;            }else{                continue;            }        }        if(i==strArray.length){            return -1;        }else{        return i;        }    }    int findLastNumIndex(String str){        char[] strArray=str.toCharArray();        int i;        for( i=strArray.length-1;i>=0;--i){            if(strArray[i]>='0' && strArray[i]<='9'){                break;            }else{                continue;            }        }        if(i==-1){            return -1;        }else{        return i;        }    }      String MyFileReader(String fileName) {          File file = new File(fileName);          StringBuilder sb = new StringBuilder();          String s ="";          BufferedReader br = null;        try {            br = new BufferedReader(new FileReader(file));        } catch (FileNotFoundException e) {            // TODO Auto-generated catch block            e.printStackTrace();        }          try {            while( (s = br.readLine()) != null) {              sb.append(s + "\n");              }        } catch (IOException e) {            // TODO Auto-generated catch block            e.printStackTrace();        }          try {            br.close();        } catch (IOException e) {            // TODO Auto-generated catch block            e.printStackTrace();        }          String str = sb.toString();          //str是你想要的东西          return str;          }}public class pychallenge06 {      public static void main(String args[]) {              new Level06();      }}

根据以上程序跑到了最后一个txt文件,文件名,文件内容如下:

channel\46145.txtCollect the comments.

让我收集注释,可是哪儿有注释,下面还怎么做,又不知道怎么玩了?
下面的工作又需要Python来完成来。
网上找的代码:

import zipfilenumber = "90052"path = "%s.txt"pattern = "Next nothing is (\d+)"zf = zipfile.ZipFile('channel.zip')comment = ''while True:    try:        text = zf.read(path % number)        print text        comment += zf.getinfo(path % number).comment        number = re.search(pattern,text).group(1)    except:        breakzf.close()print comment

这是结果:

**********************************************************************************************************************************                                                            ****   OO    OO    XX      YYYY    GG    GG  EEEEEE NN      NN  ****   OO    OO  XXXXXX   YYYYYY   GG   GG   EEEEEE  NN    NN   ****   OO    OO XXX  XXX YYY   YY  GG GG     EE       NN  NN    ****   OOOOOOOO XX    XX YY        GGG       EEEEE     NNNN     ****   OOOOOOOO XX    XX YY        GGG       EEEEE      NN      ****   OO    OO XXX  XXX YYY   YY  GG GG     EE         NN      ****   OO    OO  XXXXXX   YYYYYY   GG   GG   EEEEEE     NN      ****   OO    OO    XX      YYYY    GG    GG  EEEEEE     NN      ****                                                            ****************************************************************** **************************************************************

下面是访问hockey.html
页面显示:
it’s in the air. look at the letters.

答案是:oxygen
下一题的链接是:oxygen.html

0 0
原创粉丝点击