equal
deleted
inserted
replaced
|
1 #!/usr/bin/env ruby |
|
2 |
1 # A case of catastrophic backtracking in Ruby |
3 # A case of catastrophic backtracking in Ruby |
2 #--------------------------------------------- |
4 #--------------------------------------------- |
3 # example provided by Daniel Baldwin |
5 # example provided by Daniel Baldwin |
4 # |
6 # |
5 # |
7 # |
6 # regex: (a?){n} a{n} |
8 # regex: (a?){n} a{n} |
7 # strings: aa... |
9 # strings: aa... |
8 # |
10 # |
9 # run on the command line with: |
11 # run on the command line with: |
10 # |
12 # |
11 # ruby catastrophic.rb |
13 # ./catastrophic.rb |
12 # |
14 # |
13 |
15 |
14 nums = (1..1000) |
16 nums = (1..30) |
15 |
17 |
16 #iterate through the nums 1-1000 |
18 #iterate through the nums 1-30 |
17 nums.each do |i| |
19 nums.each do |i| |
18 |
20 |
19 start_time = Time.now |
21 start_time = Time.now |
20 string = "a" * i |
22 string = "a" * i |
21 |
23 |