 So, do you have any HQDs in the house today? Yeah? Pretty good? Represent? Alright, that's like, I'll explain HQ Trivia. Okay, so my name's Hank, and yep, I'm here to suggest to you that if at first you don't succeed at beating HQ Trivia, try cheating, and if you don't like the word cheating, we can call it tool-assisted gameplay, if that makes you feel better. Seriously, a little bit about me. I'm an iOS developer at Lyft right now. I have a cute dog named SodaPop, and I like to win. And so, just to get this out of the way, I have a little Twitter fight going on. I'm trying to get the most pictures of my dog into my presentation to be Joel, and so here's a slide that has a lot of pictures of my dog. So, we're done with that. Let's talk about HQ Trivia. So, HQ Trivia is a live trivia game. Oh, here, let me restart this. It's freezing. Should be animated. I have a lot of animated gifs in my presentation, so that's really important. Okay, yep. So, HQ Trivia is a live trivia game that you can play on your phone. You have to answer 12 multiple-choice questions. You have 10 seconds to answer each question, and you can win cash prizes if you answer all of them right. The prizes are sometimes really big, and sometimes they're like 50 cents. It just kind of depends on how many people win and what the prize is. So, what's the problem here? As the game progresses, it gets really, really hard. The questions get really, really hard. And so, if you're really just guessing randomly, the odds are really, really low that you're actually going to win. And if you're Han Solo, you might say, okay, well, I don't care. I'm just going to guess randomly. But for people like me, you probably need a little bit more help. And so, how can we be HQ Trivia? So, I had a little thought process, you know, but I can Google it really fast or I can write a neural network, but at the end, I want to write an app that will Google it really fast. And so, like, let's divide and conquer this problem. So, if you want to build an app that can play HQ Trivia, for number one, I have to get the actual question and multiple answers from my iPhone app and then put it into another app. And then after that, I have to actually make a search query that can help me decide, like, which answer I want to pick within 10 seconds, which is kind of a lot of time-pressure, kind of like this talk. Okay, so, one thing about me is I'm an iOS developer, and so, every problem that I look at, the solution looks like an iPhone app. That's not necessarily the best way to solve problems. It's kind of like if you have a hammer, everything looks like a nail. And so, originally, I wrote an iPhone app to solve this, and then eventually, I wrote a Mac app. And so, now that we know what the problem is, we know what we want to use to solve it, let's just get down to the nitty-gritty, right? Let's get this show on the road. So, step one. So, this is really good timing because Apple actually released a vision framework last year at WWC. And so, what this does, and one of the things it does is it can actually detect text rectangles. And so, you can see in the screenshot, it's actually doing a pretty good job of finding where the text is. So, you might be thinking to yourself, does this actually do OCR? And one thing that surprises people when I talk to them about vision is that it actually doesn't do the optical character recognition for you. So, you have to do it on your own. And so, oops, yeah. And so, step two is OCR. And so, originally, I was going to write, you know, or train this model to do character recognition based on like inputs from the app, screenshots and everything. But I just didn't really have time and I kind of wanted to just start winning. And so, I ended up using an open source project called Tesseract. It works really, really well. And so, that's step two. So, step three is to Google it. I was looking at the Google custom search engine API and it kind of looked like it wanted you to only choose one domain or a few multiple domains, but I really wanted was the entire internet, right? And so, what I did was I just made a get request to Google the search, like URL. And then, eventually, I got blocked and it said, hey, you're a robot. And they're partly right. I guess I was a robot. And so, I moved on to the Bing Web API. And so, I used that for a little bit, but they actually want to charge you money. And I don't want to pay money just to win HQ trivia, especially if it's like 50 cents. And so, the solution I finally ended up with is to use Safari inside of my app. And so, again, iOS and Mac, you know, you can have a web view. And so, basically, I load Google up. I use JavaScript to put the query in and then I hit the submit button. And then Google is like, okay, you're cool. You're a real person. So, another advantage to this too is that you can actually see the context of the search results page while you're trying to play HQ trivia. Okay. So, we have that out of the way. We actually still need to figure out, like, what a good search query is, right? Because this is more of a heuristic approach. There's not like an algorithm that's going to get you the right answer all the time. So, like, how can we get close to helping us decide what to put in there? So, one option I had was, you probably can't read that, but it's asking three different questions with the answer combination. And so, and then looking to see how many search results there are. And I thought this would be a good idea, but it basically tells you, like, which is most popular, not necessarily what's correct. And so, then I tried it again with all the answers. I'm just appended at the end. And then we can see here, the question is, like, what is playing music in public places called, and busking is the right answer. And here it shows up five times. And the other two times that actually showed up were in reference to the HQ trivia question itself. And so, that's pretty good. Making a small optimization for that, you can also wrap those answers in OR. And so, then what this does is it kind of prevents you from getting search results from pages that have all of those queries, or all of those answers that just kind of isolates you to the right answer. So, that's a little bit better. So, this is a screenshot of what the original iOS app looked like. It was kind of clunky, because I had to have two phones. So, I had one phone running HQ trivia, and I had another phone that I was pointing at it to do OCR. And so, this is kind of stupid. I quickly learned that there's a better way. And so, I ended up running a Mac app. And so, this is the Mac app I have currently, or almost currently. So, what it does is you air play your screen to your Mac, and then your Mac takes a screenshot of that. And then, the OCR is actually a lot better, because it's a clean screenshot. And the search results show up. So, you can kind of scan it and get a better idea of what the right answer may be. So, while I was doing research for this talk, I actually found some people who did a little bit more research and had a different way to solve the first problem. And so, there's these blog posts. I can't read them to you right now, because I'm in the middle of a talk. But I'll probably like post these somewhere, so you can read those too, because I want to give those people credit. But basically, what they found was that if you use a tool like Charles to look at the network traffic between H2 Trivia and their back end, you can actually find a web socket they can connect to. And then, you can get all of the chats and all of the question-answer combos. So, you don't have to do OCR at all. So, I basically wasted a lot of my own time. But that's because I wanted to run an app, right? And so, I looked at that, and I was like, okay, actually, I can build on top of this, right? And so, I built a new feature, and it's called Ask the Audience. So, it's like, who wants to be a millionaire? I can scan all of these chat questions. And often, people in HQ try to put in the answer that they think is right. So, like, the chat is scrolling so fast that you usually can't see it. But it-programmatically, you know, I can just look at those answers and then have a tally of them. And so, the sample question I want to use is, what word does Aretha Franklin spell out in her iconic 1967 hit? So, let's see how well this works, right? So, we're looking, counting, counting, and yes, nailed it. All right. So, yeah, if you guys remember Robocop, that was a classic song. So, yeah. In the end, it didn't really work that well, and I wasted more of my own time. And this kind of, like, validates my idea, and I think a lot of people's idea that you should never read the comments. Just never look at them. Swipe them away. So, yeah, in the end, like, how well does my solver actually do? I guess about 70 to 80% of the question's right. And that's still not good enough to win. And then there's also this weird, like, metagame you have to play, where you, not only do you have to try and figure out, like, what answer is right, you have to figure out whether or not the robot is right or not. So, it's like two games in one, and it kind of takes the fun out of it a little bit too. But so does losing. So, how can HQ actually, like, defeat cheaters? It actually does pretty well. And so, there are certain questions that Google just can't really answer very quickly. HQ can do a little bit better job with, like, certificate painting, so you can actually look at the network traffic, and they prevent quick time sessions, but for some reason they don't prevent air play. So, that's how I got around that problem. So, here's some examples of HQ questions that are hard to answer for Google. So, one of them is, if you ask things about, like, the first or the last, you know, extremes, then it's really hard for Google to come up with that. Like, the way I would do it in person is just to look at, like, a list of country names and then search each one, but you can't do that in 10 seconds. Another one is to add, like, a red herring answers, and these are kind of, like, savage questions, right? So, Jackie Robinson is known for playing for the Brooklyn Dodgers, but this question is actually asking about this minor league baseball, and so the right answer is Montreal, which most people got wrong. So, yeah, that's all, about all I have. In closing, if you want to follow me, I'm on Twitter. If you want to follow my dog, he's on Instagram. And if you haven't played HQ Trivia, you can sign up with my referral code, and I can get extra lives. And I want to actually leave with one more thought, and maybe it's that the real HQ Trivia prizes, there are technologies we learned. All right. Thank you.