Skip to content

Instantly share code, notes, and snippets.

@luckyruby
Last active August 29, 2015 14:14
Show Gist options
  • Save luckyruby/98d255be77449c6cd79d to your computer and use it in GitHub Desktop.
Save luckyruby/98d255be77449c6cd79d to your computer and use it in GitHub Desktop.
require 'http'
require 'json'
$answer = []
def extract_secret(id='start')
session_id = HTTP.get("http://challenge.shopcurbside.com/get-session").to_s
url = "http://challenge.shopcurbside.com/"
response = JSON.parse(HTTP.with_headers("Session" => session_id).get(url + id))
response.each do |k,v|
case k
when /secret/i
$answer << v
when /next/i
v.is_a?(Array) ? v.each {|i| extract_secret(i)} : extract_secret(v)
end
end
end
extract_secret
puts $answer.join
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment