Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.44 KB | None | 0 0
  1. allowed_chars = 'AS49BWXCcahpnz07'.chars
  2.  
  3. regex = File.read('regex.txt')
  4. patterns = regex.split('|')[3..-1]
  5.  
  6. unallowed_chars = Hash.new([])
  7. patterns.each do |pattern|
  8.   position = pattern.match(/\{(\d*)\}/)[1].to_i # get digits inside {}
  9.   chars = pattern.match(/\[(.*)\]/)[1].chars    # get characters inside []
  10.   unallowed_chars[position] += chars
  11. end
  12.  
  13. str = 196.times.map { |i| (allowed_chars - unallowed_chars[i])[0] }.join
  14. puts str
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement