DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Fallout 3 Terminal Hack Helper
Assists in solving Fallout 3 terminal hack puzzles
list = Array.new
puts "INPUT OPTIONS. TYPE DONE WHEN FINISHED"
while (line = STDIN.gets).upcase.chomp != "DONE"
list << line.chomp
puts "NEXT?"
end
puts list.inspect
String.class_eval do
def direct_map(another_string)
matching_letters = Array.new
given_letters = scan(/./)
letters = another_string.scan(/./)
given_letters.each_with_index { |letter, index|
matching_letters << letter if letter==letters[index]
}
return matching_letters
end
end
hash = Hash.new
list.each { |word|
score = 0
(0..list.length-1).each {|comp_word| score += word.direct_map(list[comp_word]).size}
hash[word] = score
}
puts "BEST INITIAL CHOICES:"
max = hash.values.max
hash.each { |k,v|
puts k if v == max
}
lengths = list.collect{|word| word.length}
raise "Different lengths #{lengths.uniq}" if lengths.uniq.size > 1
while list.size > 2
matching_list = Array.new
puts "Guess?"
input = STDIN.gets
puts "Number correct?"
input_correct = STDIN.gets.chomp.to_i
list.delete(input)
list.each{|word|
matching_letters = input.direct_map(word)
puts "#{word}:#{matching_letters.inspect}"
matching_list << word if matching_letters.length == input_correct
}
list = matching_list
puts list.inspect
end
if list.length == 0
puts "NO MATCHES"
else
puts "MATCH #{list[0].inspect}"
end
puts matching_list.inspect





