Last active
September 25, 2015 13:50
-
-
Save stevenpetryk/67e16099c40a979c3060 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MAX_RUNS = 100 | |
MAX_STATES = 500 | |
MAX_ALPHABET_SIZE = 10 | |
def get_random_dfa | |
lines = [] | |
states = (0..(1 + rand(MAX_STATES - 1))).to_a | |
alphabet_size = 1 + rand([MAX_ALPHABET_SIZE, states.count].min - 1) | |
accept_states = states.sample(1 + rand(states.count - 1)) | |
lines << "#{states.count} #{alphabet_size}" | |
lines << "#{accept_states.count} #{accept_states.join(' ')}" | |
states.count.times do |n| | |
lines << (0...alphabet_size).map do |letter| | |
states[letter * rand(5) % states.count] | |
end.join(' ') | |
end | |
lines.join("\n") | |
end | |
puts MAX_RUNS | |
MAX_RUNS.times do | |
puts get_random_dfa | |
puts | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment