Created
March 29, 2012 03:33
-
-
Save rodvlopes/2233011 to your computer and use it in GitHub Desktop.
Lista de respostas das questões do concurso de analista de sistemas da Petrobras
This file contains hidden or 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 | |
# encoding: utf-8 | |
PROVAS = { | |
:petro_pro_2010 => %q(A,C,A,B,E,B,E,A,C,B,B,E,B,D,A,B,C,E,E,B,D,D,E,E,D,C,C,E,D,A,C,A,A,D,E,D,A,B,C,A,A,A,D,E,C,D,A,E,A,B,D,D,A,A,E,C,D,E,B,D,E,D,A,A,B,A,C,D,E,B).split(','), | |
:petro_eng_2010 => %q(C,B,B,E,A,E,E,D,A,D,A,B,C,A,B,C,D,B,E,C,A,E,D,C,C,B,E,E,B,A,D,B,B,A,A,C,A,D,A,C,C,B,D,D,D,D,A,D,E,C,E,B,E,D,A,B,B,X,A,B,E,C,X,D,A,B,C,D,D,E).split(','), | |
:petro_eng_2011 => %q(C,D,B,A,A,A,E,B,C,A,C,A,A,C,E,B,D,D,E,D,E,C,D,A,D,B,A,A,C,C,A,B,D,D,E,C,B,C,C,X,D,A,E,C,C,A,B,C,B,E,B,C,E,A,C,C,E,C,D,A,D,E,A,A,B,X,A,E,A,B).split(',') | |
} | |
def main | |
if ARGV.empty? | |
puts 'Uso: ./respostas.rb <prova> <questoes separados por virgula>' | |
puts '' | |
puts PROVAS.keys | |
exit(0) | |
end | |
prova, questoes = extract_args | |
answers = answers_for(prova, questoes) | |
puts "Respostas: #{answers}" | |
end | |
private | |
def extract_args | |
prova = ARGV[0].to_sym | |
raise 'Prova não encontrada.' unless PROVAS.keys.include?(prova) | |
questoes = ARGV[1] ? ARGV[1].split(',').collect! {|i| i.to_i} : [] | |
raise 'Nenhuma questão.' if questoes.empty? | |
return prova, questoes | |
end | |
def answers_for(prova, questoes) | |
answers = {} | |
questoes.each {|q| answers[q.to_s] = PROVAS[prova][q-1]} | |
answers | |
end | |
class Hash | |
def to_s | |
s = '' | |
each{|k,v| s += "#{k}: #{v} "} | |
s | |
end | |
end | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
tem que ter o ruby >= 1.8.7 instalado