Zak Wegweiser


What it does

My HQ answerer is a PHP script triggered by a screenshot upload. You take a picture of a multiple choice trivia question (in this case three answer choices), and my answerer uses Optical Character Recognition (OCR) to decipher the text and then figures out the most relevant answer.

How I built it

The front-end is a basic Automator script, but could be anything that sends a trivia question to my server. The back-end is written in PHP. I did this to allow it to be stored on the server. I used Google's Vision API to decipher the text and Google's Custom Search API to Google the answer.

I run three techniques in parallel to quickly figure out the correct answer:

  • Simply google the question and search for all the answers. This trick works roughly 50% of the time, but can be thrown off by simple "Which of these..." questions.
  • Count the overall search results. Every time you search something on google you see something like: About 1,330,000,000 results (0.65 seconds). I google the question with all three answer choices appended to find the most popular answer.
  • Finally, I backtrace by googling each question with one answer choice and check how many times it appears in the first four non-Wikipedia results (Wikipedia screws up results kids!)

I then take all of the calculations and add up the total counts and percentages to conclude my final answer.


As many of you know HQ is the new big hit trivia game that gives you less than ten seconds to answer a multiple choice question. Answer 12/12 questions you win money. Sounds easy right? Well, I thought so too until I lost consistently for over a month. That is when I decided to create my HQ answerer. Now just note, it is obviously against the HQ terms to use something like this during a live game. But it is a lot of fun to use afterward.

Challenges I ran into

There were a plethora of challenges I experienced over the course of this project.

  1. Most importantly, accuracy. It took forever to find the right way to scrape Google to accurately calculate the correct answer.

  2. Also, speed. I had to run each query in parallel, to get the answer in under 7 seconds.

  3. Finally, adjusting to different types of questions. Questions like "Which of these..." or "Who has NOT..." were tough questions to solve. I had to adjust to the question. "Which of these" questions were more easily solved through my third technique of back-solving (explained above). I found it easiest to solve, "NOT" questions, by actually removing the word "NOT" from the query and then picking the "worst" answer choice. It worked!

Accomplishments I am proud of

I learned a lot during this project, including parallelizing queries, working with Google APIs, and finding clever solutions for problems that were intended to be deceitful!