![]() ![]() I’m going to use the Faraday gem for making web requests, since it has a simple interface that I know well. Looks like the URL format for searching is just a simple query string, That’s easy enough. Obviously this site has no API, so I’ll need to scrape the website directly. So we’re looking at an average of 36 \* (20/2 + 2) = 36 \* 12 = 432 iterations.įirst things first: I need to write a client that can programmatically query the search box. Let’s assume we have 20 characters in our password, and an alphabet consisting of a-z (26) and 0–9 (10), so a total alphabet size of 36. So the total is A/2 \* L + 2A, which we can factor as A(L/2 + 2). To be precise, I also have to add another 2A to the number of guesses for ascertaining that the string has terminated on each end. In total, I’ll need to figure out L characters (where L is the length), and need to expend on average A/2 guesses per character (where A is the alphabet size), so total guesses = A/2 \* L. Once the process terminates, I should be able to reconstruct the password. Easy enough: all I have to do is now repeat the process, except going backwards. I’ll keep building this substring until it eventually hits the end and no characters can extend it further.īut that’s not enough-most likely, there will be a prefix to the string that I missed, because I started in a random place. Any of those characters could be correct, so on average it’ll hit somewhere around the middle, so given an alphabet of size A, it should average out to A/2 guesses per letter (let’s assume the subject is small and there are no repeating patterns of 2+ characters). We’ll potentially have to iterate through every character in our alphabet to find it. But I know I can start building out a bigger substring by appending different characters to the end of this until I hit another substring match. Once I’ve found my first letter, I don’t actually know where in this string I am. ![]() We keep trying letters one by one until we hit a match for something that’s not in our subject line. So if we take all of the characters that aren’t in the subject and try searching for each of them, we know for sure we’ll hit a unique letter that’s in the password. So we’ve got six slots of characters, some of which may appear in the subject line, some of which certainly don’t. Let’s pretend the body is 6 characters long. We also have a subject line as part of the string we’re querying. I probably didn’t include any upper-case characters (and Reddit doesn’t enforce that as a password constraint) so let’s assume for now that I didn’t-in case I did, we can just expand the search space later if the initial algorithm fails. A few things I know about my password: I know it was a long string with some random characters, probably something along the lines of asgoihej2409g. Given this function, write an algorithm that can deduce the hidden password. I hurry into my apartment, drop my bag, and pull out my laptop.Īlgorithms problem: you are given a function substring?(str), which returns true or false depending on whether a password contains any given substring. By entering in a string into the search bar, the search results will confirm whether my password contains this substring. Remember: the body consisted entirely of my password.Įssentially, I’ve been given an interface to perform substring queries. I pulled up the app on my mobile phone and tried it: ![]() I was walking home that night from the office pondering my predicament, when suddenly it hit me. I started brainstorming elaborate explanations involving dead relatives about why I needed access to the e-mail…Īll of my options were messy. Not to mention it would be an embarrassing e-mail exchange. Plus this site doesn’t look like it has a support team. We’ve already established I’m wildly impatient. But they would probably take a while to get back to me. I could write in to LetterMeLater and explain that I didn’t mean to do this. What do I do? Do I just have to create a new Reddit account and start from scratch? But that’s so much work. I also set it to “hide,” so I couldn’t view the contents of the e-mail until it’s sent. I didn’t remember doing this, but I must have gotten so fed up with myself that I locked myself out until 2018. I decide to scrounge up my old account and find my Reddit password. This means waiting, and waiting of course means internet rabbit holes. And Airbnb, it so happens, has a large test suite. It worked quite well from what I remember.Įventually I got so busy with programming stuff, I completely forgot about it. Perfect-an automated, friend-less solution! (I’d alienated most of them by now, so that was a big selling point.)Ī bit sketchy looking, but hey, any port in a storm.įor a while I set this up this routine-during the week I’d e-mail myself my password, on the weekends I’d receive the password, load up on internet junk food, and then lock myself out again once the week began. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |