1. #
  2. # Finish the delta debug function ddmin
  3. #
  4.  
  5. import re
  6.  
  7. def test(s):
  8. print s, len(s),repr(s)
  9. if re.search("<SELECT[^>]*>", s) >= 0:
  10. print (s, len(s),"FAIL")
  11. return "FAIL"
  12. else:
  13. return "PASS"
  14.  
  15. def ddmin(s):
  16. assert test(s) == "FAIL"
  17.  
  18. n = 2 # Initial granularity
  19. while len(s) >= 2:
  20. start = 0
  21. subset_length = len(s) / n
  22. some_complement_is_failing = False
  23.  
  24. while start < len(s):
  25. complement = s[:start] + s[start + subset_length:]
  26.  
  27. if test(complement) == "FAIL":
  28. s = complement
  29. n = max(n - 1, 2)
  30. some_complement_is_failing = True
  31. break
  32.  
  33. start += subset_length
  34.  
  35. if not some_complement_is_failing:
  36. # YOUR CODE HERE
  37. if len(s) == n:
  38. break
  39. n = min(n * 2, len(s))
  40.  
  41. return s
  42.  
  43. # UNCOMMENT TO TEST
  44. html_input = '<SELECT>foo</SELECT>'
  45. print ddmin(html_input)

Simplifying Failures的更多相关文章

  1. Too many authentic authentication failures for root

    连接SSH服务器时报 Too many authentic authentication failures for root. 方法一:删除目标服务器 /root/.ssh/目录下的 known_ho ...

  2. SSH returns “too many authentication failures” error – HostGator

    I am an avid fan of using HostGator for small business WordPress website hosting. I love that they u ...

  3. Too many authentication failures for xxxx_username

    解释 这个报错通常是因为多个ssh key 验证,key太多了导致服务器拒绝接受认证请求. 可以通过 -v 参数,输出详细的过程.你会发现你提供的认证key,服务器拒绝链接,并提示异常:"T ...

  4. error——Fusion log——Debugging Assembly Loading Failures

    原文 So...you're seeing a FileNotFoundException, FileLoadException, BadImageFormatException or you sus ...

  5. SSH File Transfer遇到错误"too many authentication failures for root".A protocol error was detected......

    在SSH  Secure Shell 连接Linux centos的时候,遇到F-Secure SSH File Transfer错误"too many authentication fai ...

  6. maven编译时出现There are test failures

    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.10:test (default-tes ...

  7. Error: 实例 "ddd" 执行所请求操作失败,实例处于错误状态。: 请稍后再试 [错误: Exceeded maximum number of retries. Exhausted all hosts available for retrying build failures for instance 6f60bc06-fcb6-4758-a46f-22120ca35a71.].

    Error: 实例 "ddd" 执行所请求操作失败,实例处于错误状态.: 请稍后再试 [错误: Exceeded maximum number of retries. Exhaus ...

  8. Maven进行install的时候报错,COMPILATION ERROR : Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.13:test (default-test) on project cmu: There are test failures.

    maven进行install的时候,test类里面报错: COMPILATION ERROR : [INFO] -------------------------------------------- ...

  9. (org.jbehave.core.failures.BeforeOrAfterFailed: webdriver selenium错误解决。

    (org.jbehave.core.failures.BeforeOrAfterFailed: Method initWebDriver (annotated with @BeforeStory in ...

随机推荐

  1. [C#(WinForm)]判断第一次启动程序

    来源:https://bbs.csdn.net/topics/220023353/(10楼) 在判断窗口上添加: string strIsFirstRun = "false"; b ...

  2. Programmingbydoing

    http://www.programmingbydoing.com/ 1. Modulus Animation public static void modulusAnimation() throws ...

  3. Python学习日记(二十二) 初识面向对象

    引子 假设我们要开发一个关于飞机大战的游戏,那么游戏的里面就会有两个角色,分别是属于玩家操控的战机和敌方的战机,并且两个战机都有不同的技能或攻击方式,现在我们用自己目前所学的去写出下面的这些代码: d ...

  4. p7.BTC-挖矿总结

    全节点: 1 一直在线 2 在本地硬盘上维护完全的区块链信息 3 在内存里维护UTXO集合,以便快速检验交易的正确性 4 监听比特币网络上的交易信息,验证每个交易的合法性 5 决定哪些交易会被打包到区 ...

  5. redis哨兵配置 总结

    本文内容涵盖 windows下单机部署redis多实例(docker.linux下的配置也可参考本文) redis主从配置 redis哨兵配置 以spring boot redis demo下一个存a ...

  6. System V共享内存

    目录 1. 概述 2. System V共享内存API shmget shmat shmdt shmctl 3. 简单的程序 代码实现 common.h shmcreate.c shmrmid.c s ...

  7. ISCC之msc4

    一开始拿到题目的时候有点懵的,给个gif图片,233 常规分析,gif打开看一看,发现gif是多张图片组成,于是用fastStone Image viewer分解成九张图片 后面用PS拼起来,得到一个 ...

  8. PTA-多项式A除以B

    多项式A除以B 这仍然是一道关于A/B的题,只不过A和B都换成了多项式.你需要计算两个多项式相除的商Q和余R,其中R的阶数必须小于B的阶数. 输入格式: 输入分两行,每行给出一个非零多项式,先给出A, ...

  9. JDK源码那些事儿之SynchronousQueue下篇

    之前一篇文章已经讲解了阻塞队列SynchronousQueue的大部分内容,其中默认的非公平策略还未说明,本文就紧接上文继续讲解其中的非公平策略下的内部实现,顺便简单说明其涉及到的线程池部分的使用 前 ...

  10. asp、aspx、php、jsp万能密码大全【笔记】

    asp aspx万能密码 1:"or "a"="a 2: ')or('a'='a 3:or 1=1-- 4:'or 1=1-- 5:a'or' 1=1-- 6: ...