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
- PythonChallenge第6题
- pythonchallenge 【第0题】
- pythonchallenge 【第1题】
- pythonchallenge 【第2题】
- pythonchallenge 【第3题】
- PythonChallenge第0题
- PythonChallenge第3题
- PythonChallenge第4题
- PythonChallenge第5题
- PythonChallenge第7题
- PythonChallenge第8题
- PythonChallenge第9题
- PythonChallenge第10题
- pythonchallenge第0关
- [PythonChallenge]第0关
- [PythonChallenge]第1关
- [PythonChallenge]第2关
- [PythonChallenge]第3关
- 第八周【项目1-实现复数类中的运算符重载】
- SQL学习记录2 创建和使用数据库(weiwancheng)
- zoj 4704 Unrequited Love 贪心 孤独者
- 正则表达式学习笔记(一)
- 算法导论笔记:08线性排序
- PythonChallenge第6题
- Java 中的 static 使用之静态方法
- HDU 2010
- java数组的定义
- 电信141p122第16题
- 作业
- jquery uploadify 上传控件ASP.NET使用总结
- 2015-4-23
- poi导出Excel的两种方式