Line    , P, H, #, SET
0x53e9e0, 0, 0, 1, 55
0x53ea18, 0, 0, 2, 55
0x53ea50, 0, 0, 3, 55
0x53ea18, 0, 1, 4, 55
0x53ea88, 0, 0, 5, 55
0x53eac0, 1, 0, 6, 55
0x53ea18, 0, 1, 7, 55
0x53eaf8, 0, 0, 8, 55
0x53eb30, 1, 0, 9, 55
0x53eb30, 0, 1, 10, 55
0x53eb68, 0, 0, 11, 55
0x53eba0, 1, 0, 12, 55
0x53ebd8, 1, 0, 13, 55
0x53ec10, 0, 0, 14, 55
0x53ec48, 1, 0, 15, 55
0x53ec48, 1, 1, 16, 55
0x53ec80, 0, 0, 17, 55
0x53ecb8, 0, 0, 18, 55
0x53ecf0, 1, 0, 19, 55
0x53ecf0, 0, 1, 20, 55
0x53ed28, 1, 0, 21, 55
0x53e9e0, 1, 0, 22, 55
0x53e9e0, 0, 1, 23, 55
0x53e9e0, 1, 1, 24, 55

For every set ranging from 0 to 1024 and occurring in any order (above I printed only the first 25 of the 55th set). I want to see for every line, with P==1 before it and having a H==1 after it. I want to know how many runs have gone through if it is less than 16.

对于范围从0到1024并且以任何顺序发生的每个集合(上面我仅打印了第55集中的前25个)。我希望看到每一行,前面有P == 1并且后面有一个H == 1。我想知道如果它少于16,已经完成了多少次运行。

For example: Consider line:0x53e9e0 in physical line 2 has P and H as 0. In line the last but third line (line 23), 0x53e9e0 reoccurs but more than 16 runs have gone through (so it is considered as a new line) However, line 23 and 24 have a difference of 1.

例如:考虑线:物理线2中的0x53e9e0具有P和H为0.在最后但第三行(第23行)中,0x53e9e0重新出现但超过16次运行(因此它被视为新行)但是,第23行和第24行的差异为1。

There are multiple such lines with a difference of 1-16. I want to find all those lines on a per set basis.

有多条这样的线,相差1-16。我想在每套基础上找到所有这些线。

1 个解决方案

#1


1

lines = """0x53e9e0, 0, 0, 1, 55
0x53ea18, 0, 0, 2, 55
0x53ea50, 0, 0, 3, 55
0x53ea18, 0, 1, 4, 55
0x53ea88, 0, 0, 5, 55
0x53eac0, 1, 0, 6, 55
0x53ea18, 0, 1, 7, 55
0x53eaf8, 0, 0, 8, 55
0x53eb30, 1, 0, 9, 55
0x53eb30, 0, 1, 10, 55
0x53eb68, 0, 0, 11, 55
0x53eba0, 1, 0, 12, 55
0x53ebd8, 1, 0, 13, 55
0x53ec10, 0, 0, 14, 55
0x53ec48, 1, 0, 15, 55
0x53ec48, 1, 1, 16, 55
0x53ec80, 0, 0, 17, 55
0x53ecb8, 0, 0, 18, 55
0x53ecf0, 1, 0, 19, 55
0x53ecf0, 0, 1, 20, 55
0x53ed28, 1, 0, 21, 55
0x53e9e0, 1, 0, 22, 55
0x53e9e0, 0, 1, 23, 55
0x53e9e0, 1, 1, 24, 55"""

last_seen = {}
for i, line in enumerate(lines.split('\n')):
    id = line.split(',')[0]
    if id in last_seen:
        last_i = last_seen[id]
        delta = i - last_i
        if delta <= 16:
            print("last seen {} at {}, {} lines ago.".format(id, last_i, delta))
    last_seen[id] = i

Output:

输出:

last seen 0x53ea18 at 1, 2 lines ago.
last seen 0x53ea18 at 3, 3 lines ago.
last seen 0x53eb30 at 8, 1 lines ago.
last seen 0x53ec48 at 14, 1 lines ago.
last seen 0x53ecf0 at 18, 1 lines ago.
last seen 0x53e9e0 at 21, 1 lines ago.
last seen 0x53e9e0 at 22, 1 lines ago.

更多相关文章

  1. Linux环境下注册函数的调用顺序
  2. 检查mysql中的行顺序
  3. 使用desc后的sql server反向顺序
  4. sql语句中各子部分的执行顺序
  5. mysql在组通过之前获得顺序
  6. Java se之静态代码块、代码块、构造函数执行顺序问题
  7. Java普通代码块,构造代码块,静态代码块区别,执行顺序的代码实例
  8. 通过不在android游标中工作的顺序
  9. Android Robotium如何管理测试用例的执行顺序?

随机推荐

  1. 如何在Android真机上检测是否有Google Ma
  2. Android layout xml总结(2)
  3. 整理 酷炫 Android、Flutter 开源UI框架
  4. Android---Menu
  5. android 2D教程精华集合贴
  6. android各种广播简介
  7. 【转】每个Android开发者都应该了解的资
  8. android设置全屏以及解决设置全屏无效的
  9. android 权限配置和测试环境配置
  10. 【基于Android的ARM汇编语言系列】之六:NE