Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Lista de respostas das questões do concurso de analista de sistemas da Petrobras
#!/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
@rodvlopes

This comment has been minimized.

Copy link
Owner Author

commented Mar 29, 2012

Para executa-lo direto do github, no shell rode o comando:
ruby <(curl -s https://raw.github.com/gist/2233011/8dda3e56244a27b7afe440169d3a9b8a800c8dd0/repostas.rb)

@rodvlopes

This comment has been minimized.

Copy link
Owner Author

commented Apr 4, 2012

baixe o script

wget https://raw.github.com/gist/2233011/bbaae177d2a0e3598ed92005cbb9be6c3e6fa006/respostas.rb

dê permissão de executar

chmod a+x respostas.rb

execute. pegue a resposta da questão 3 do processo de negócio de 2010

./respostas.rb petro_pro_2010 Respostas: 3: A

@rodvlopes

This comment has been minimized.

Copy link
Owner Author

commented Apr 4, 2012

tem que ter o ruby >= 1.8.7 instalado

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.