大神级的问题!

livesguan 2013-07-19 07:15:51
I have a file of list of integer tuples (one per line) could be pretty long (could have around 1 million lines), input format in this way, for example:
30 40
3 100
34 900
200 1000
24 9000
4000 20000
3000 8000
30000 30040

(The integer tuple means line segment on the X axis, all positives, first number is always less than 2nd number. Eg: 30 40 means a line segment with length of 50.)

Write a python program:
Please Write a python program, print out all pairs of segments that overlaps with each other. For example: [40 200] overlaps with [10 90], and overlaps with [140 500], but not with [400 500] or [10 20], we define that [10 20] does not overlap with [20 40])

...全文
165 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
赵增光 2013-07-24
  • 打赏
  • 举报
回复
100万的数据,不涉及排序,只是格式化输出的话,还是写到文件里,逐行/逐块读出来比较简单。

37,719

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧