Last active
December 15, 2015 20:58
-
-
Save anonymous/5321997 to your computer and use it in GitHub Desktop.
pangur's file
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
#!/usr/bin/env ruby-2.0.0 | |
contents = File.read('wlc.txt') | |
text = [] | |
@nums = [] | |
@questions = [] | |
@answers = [] | |
@combined = [] | |
i = 0 | |
puts "----------" | |
contents.each_line do |line| | |
text << line.chop | |
end | |
text.each do | thing | | |
if thing.start_with?('Q. ') | |
num, question = thing[3..-1].split(' ',1) | |
@nums << num | |
@questions << question | |
elsif thing.start_with?(' A. ') | |
answer = thing[4..-1] | |
@answers << answer | |
elsif thing.start_with?(/[0-9]/) | |
answer << thing | |
@answers << answer | |
end | |
end | |
@combined = @nums.zip(@questions, @answers).each do |num,question,answer| | |
end | |
@combined.each do |what| | |
puts what | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment