The Coding Challenge

I finally got what I’ve been asking for, an opportunity to bypass all the crap I’ve complained about, an opportunity to show a potential employer what I can actually do, an opportunity to show what I’m capable of, an opportunity that may not present itself again …. and I fucked it up.  Yeah, you know it’s serious when I use that kind of language.

First let’s go back to my last post, one I’m not exactly proud of, but this blog is about my journey, the good and the bad.  In that mess of negativity and whining, I mentioned one company I applied for whose CEO was quoted as saying that he only cares about what a person is capable of and not they’re background.

In that application I was given an assessment.  One of those aptitude tests that have absolutely nothing to do with programming followed by a personality test.  You know the one, where you’re asked things like “have you ever stolen something” and then asked that same question 5 more times but reworded to try and trip you up.  Well, I never made it past that. I know I KILLED the aptitude portion, which means there was something in my personality assessment they didn’t like.  Man, talk about feeling rejected.  It’s different when it’s personal like that.

So about a month ago I was at a local React meetup and met a person who was working with someone who filled in most of their senior and mid level developers and were about to start on filling in with juniors.  Fast forward almost 2 weeks and I got a call from this person.  He started to talk about the position and I recognized it right away.  He told me the company name and I smiled.  It was the same one I had already been rejected from because of the assessment tests.

I go on to tell him about it and he agreed that those assessments are a ‘crock of shit’ and that even the director at the company was opposed to it, but it was an HR thing.  Well, it just so happened that they figured out a work-around, and he needed people quick.  I’m getting pretty excited at this point, I already know what the company does and would love to be a part of it, and as a bigger bonus, their office is literally less than 2 miles from my home!  In so many ways this was the perfect role for me, and finally, the stars were starting to align!

All I needed to do was take their coding challenge, completely bypassing all the initial crap.  I even felt like the person I was speaking to was rooting for me.  He told me if I knocked it out of the park that I would be ‘golden’ and it would be a big ‘F U’ to that stupid assessment.  I can’t even begin to describe the level of excitement going across the phone.

I get the challenge e-mailed to me, and start digging in to it.  This is going to be fun, I get to finally prove myself, and dive into a topic I haven’t had a chance to before, cryptography!

The challenge provided 3 files, 2 of which were encrypted and a regular plain text file.  At a minimum, I had to write an algorithm that would decrypt the easier of the 2 encrypted files using the plain text file as a base.  As an added bonus, and to really impress, I would of had to also decrypt the harder version, and could create an API and/or a Single Page App (SPA).

So where do I begin? I had no clue, other than the Little Orphan Annie decoder pin from ‘A Christmas Story’ and having recently watched the movie ‘The Imitation Game’ about Alan Turing, I knew absolutely NOTHING about cryptography.  It’s always seemed an interesting field and from what I knew you could spend years trying to master it.

Not knowing anything, I go to a developers best friend, google. I start reading up on some basics of cryptography and really just barely scratch the surface with the different types of ciphers that can be used in a ‘simple substitution’ encryption.  Think ‘A Christmas Story’ here where you simply substitute a letter with another one.  The simple part is that the substitute letter never changes.

At this point I figure the easy encrypted version has to be one of these simpler substitutions.  Especially after looking at the text patterns I could just tell that these letters weren’t changing.

But how do I use the plain text?  The instructions said to use it as a base, but I had no clue what that meant, and didn’t find anything anywhere that talked about ‘using plain text as a base’.  I ended up assuming that the encrypted text was from some part of this plain portion (which was over 5 million characters long).  And since all the spacing, punctuation, and capitalization was preserved, I decided to try and find where the word letter count, spacing, punctuation, etc. matched between the two versions.  Once I found that, I started writing out the letter substitutions.  Things were coming together and I noticed a pattern, which I could instantly see matched a couple of the types of ciphers I read about earlier.

Once I knew the type of cipher used, I was able to write up an algorithm to find it on it’s own.  One requirement of the challenge was to not ‘brute force’ the solution as the cipher could change anytime.  While the algorithm I created could figure out the cipher no matter what the substitutions were, it did have to know what TYPE of cipher is used to work, and in this case one specific type.  So not technically brute force.  Plus I was explained ‘brute force’ meant not hardcoding the cipher as in ‘A’ is always ‘F’, ‘B’ is always ‘C’, etc., and my solution definitely wasn’t that.  The letters could have been substituted with anything and still worked.

With that part done, I decided to start on some sort of SPA.  I decided to write it up using the MEAN stack, leaving out the M since I didn’t need a database for anything.  So it’s all JavaScript built on Node.js with Express.js and Angular.  I was trying to make something that would hopefully impress so I used Angular 1.x since the majority of my experience is with that version.  I didn’t want to waste time trying to use something I had to learn at the same time.

During this time, I got a follow-up call from the person who got me this chance to see how I was coming along.  I had told him and he seemed excited about my progress.

I didn’t have any time limit but it was coming close to a week and I figured I had to get something turned in.  Of course I had a bunch of other things going on so I didn’t actually have all of that time to dedicate to this challenge.  I knew I wasn’t going to have my SPA where I wanted it in the time I allowed myself so I took on the harder encrypted challenge.

My algorithm wasn’t even close to working on this one, which I expected.  And unlike the easy version, whatever this translated to, it wasn’t going to be found within the plain text.  So now I had to rack my brain trying to figure out what to do.  I began searching google for other types of substitution ciphers (even though this was harder it still looked to me like a simple substitution), and stumbled upon a short article about frequency analysis.  Basically what this does is just use the most commonly found letters, words, etc. and starts substituting them.  Based on the odds, this could get you something to work with.

First I started with one letter words, which there are really only 2, ‘I’ and ‘A’.  I found all of the one letter occurrences and started my cipher.  These are actually easy to find because ‘I’ is always capitalized when used, versus ‘A’ which can be either.  This time, I was hard coding, a.k.a ‘brute forcing’, the cipher and using my previous decryption algorithm to start decrypting the text, leaving spaces for the letters I haven’t figured out yet.  Then I looked at 3-letter words, specifically ‘and’ and ‘the’, which are the most common of all of them. I already had the ‘a’ figured out so I could tell which one was which and added those letters to my cipher.  Decrypt again and things were looking good.  Next I looked for twin letters.  There’s not many of those either and ‘LL’ is the most common.  Added that to my cipher, decrypted, and things were starting to look up.  I started looking at other more common things, like after an apostrophe you normally see either a ‘t’ or ‘s’.  I already had the ‘t’ so the ‘s’ was easy to figure out.  Decrypt again and now it became a game of Wheel of Fortune.  Words were coming together and I was feeling just like young Ralphie, licking my lips with excitement and anticipation of figuring out the encryption.

Finally I figured it out, except there was a problem.  Looking at the cipher, there was absolutely no pattern at all to the substitutions.  Nothing to tell me what type of cipher was being used or how it was made.

My personal time limit was nearing an end.  The hard encryption was a bonus anyway so I said I had to brute force it but at least I figured it out on my own.  All the code was up on github and I told him he could submit it.  I was having a lot of fun with this though and told him that I would keep working on it anyway and would be updating github as I continued.

That was a couple weeks ago, and I haven’t heard anything since.  But I kept working on it.  I even got my SPA somewhat presentable and went ahead and deployed it live via AWS EC2.  As soon as I did that I called him up and left him a message to get an update and tell him about my new progress.  I emailed him as well and included the IP address.  That was about a week ago, again, still haven’t heard anything back.

At this point it’s safe to say what I had wasn’t good enough, this job just isn’t going to happen.  I had my chance, the one chance I’ve been begging for, and I blew it.  I didn’t crush this challenge like I believed I could.

I wasn’t lying though about enjoying this challenge, so I kept working on it, trying to figure out how to get a computer to figure out what I did on my own.  Then one night, as I was half asleep, it hit me like a Mack Truck.  Using the plain text as a base didn’t mean it contained the encrypted message (even though it actually did for the easy version).  It was all about the ‘frequency analysis’ I did myself, and what I should have done, is created an algorithm to parse through the plain text and determine the frequency of letters, words, patterns, etc.  Then using those frequencies, have the computer figure out what to start replacing the same way I did.  Then it was a matter of getting the computer to play ‘Wheel of Fortune’ to fill in the gaps.

And now we come to today.  I’m currently working on getting the algorithm to work.  I’m partially there, but it’s a bit ugly with a lot of conditionals.  For the ‘Wheel of Fortune’ part, I plan to use a word or dictionary API to cross-reference the words.  One issue I know is going to come up is made up names, names that aren’t going to be like any word in a dictionary.  But one step at a time for now.

This challenge has turned into a full-blown project for me, one that is going to be on my portfolio.  I have a vision for it and once I make it a reality, it’s going to be impressive.  It might be too late for the original position I was vying for, but I’m going to make sure it helps me with the next.

Before I end this post, I have one last thing I want to say:

He okpe ms lpytw dskp Sjcvmyte!

In case you can’t figure it out, just go to the ‘decrypt your text’ section of my app and use the keyword ‘challenge’.  It’s still in its early stages of development so don’t expect anything too amazing….yet!

Cryptography and Ciphers

Guest Post – My job getting process

**Note from the editor – Ha, I guess I can call myself an editor now too! Up until now, all the posts in this blog have been mine, this one is not. This is a guest post from one of my cohort-mates at Coding Dojo. Since he decided to name himself as ‘SuperSecret’ I won’t reveal who he is, but I will give out one clue, he was featured as a Coding Ninja in one of my previous posts. For those in my cohort, you obviously know who this is. I want to congratulate him on the job and also say thank you for taking the time to write this very informative post. There’s some really great info in here for anyone getting into the tech field.**

Hey guys, I just got a job recently and figured that id write something up about it. Basically I went on at least 9 or 10 interviews since I’ve been back, and funny enough, most of them were for junior java developer roles. I got the interviews from recruiters calling me directly (I had my resume posted on, but I’ve been told that most companies have a linkedin and a lot of recruiters get to people through that.  I knew a bit of java from college, but after doing this bootcamp it should be easy for the rest of you guys to learn. Now to start off, let me give you a bit of background on how my situation went (from college till now), and then translate that into my spiel that I became good at telling people.

(what actually happened)

I really wasn’t feeling college too much, so after graduating with a degree in math in 2014, i pretty much no idea of what to do. I really didn’t have the grades to get picked up for a good junior level job, and I had no solid direction. I lived at home for a bit, and started taking industry certification classes because i needed some extra padding on my resume (Security+, CCNA, CEH, CPT). I was a tutor for elementary through university level students, and was playing around with that whole ‘make money online’ stuff. that ‘make money online’ stuff really just entailed some SEO and building out webpages using WordPress, which requires virtually no coding knowledge. i didn’t make too much money from it, but it was still a good experience. as i realized that i need to get a real job because having no money sucked, i started trying to re-learn some java to apply for a junior level position. I tried creating an application to automate a money making scheme called ‘online retail arbitrage’, but i never ended up finishing the application. I ended up taking Coding Dojo because i had started interviewing for junior level developer positions and had no idea of what anyone was talking about during the interviews, and didn’t get any offers or jobs.

now take all of that, smooth out the edges, and you get:

(this is roughly my spiel)

I graduated in 2104 with a math degree. After that, I got into the whole ‘make money online’/e-commerce/affiliate marketing thing, and that got me through until now. I just got back from a 4 month coding bootcamp, where i learned to develop web applications in the LAMP, MEAN, and Ruby on Rails stacks. I also am familiar with python, as I have become very interested in artificial intelligence/data science, and have used python to explore some of the related packages/libraries such as numpy and scipy. I have also begun learning c, because id like to understand how software utilizes memory better, and the class that i am taking on operating systems requires an understanding of c.

(if I was asked why i am looking for a new position, i would say:)

because most of my education and knowledge has come through self study, I have come to realize that there is a point at which learning on your own is much slower than working with a group of people who know more than you do. I’ve come into a more traditional work environment because I understand that there is a lot for me to learn from more experienced developers, and i really think that this is the right decision to take my coding abilities to the next level.

so, obviously, when you want to get the job, don’t come off as desperate. I’ve noticed that a big thing that helps is make it seem like any programming that you’ve done so far has just been something that you’ve been successful in, and now you’re just looking to be in a traditional job environment. now you can come off as a fresh chick and take what you can get, but i feel like my salary negotiating power increased with the “id like to work in a more traditional work environment to increase my abilities” approach. also, having several interviews in a short time frame was great for my interviewing rapport. you get into the ‘gaming’ aspect of interviewing, where its just another interview, and learn the kinda buzzwords that people like to hear.

alright enough of that, into the interview type questions. some people didn’t know what MEAN or LAMP means, so when talking with both recruiters and hiring people, make sure to list out what each letter/technology is in the stack. plus it makes you look like you know 4 technologies rather than just 1 acronym.

i only got 2 algorithm questions, which were:

1) in any language, write a function that iterates through a string and prints out each letter

2) in any language, write a function that prints every number 1 – 100, and if the number is a multiple of 3, print ‘foo’, if the number is a multiple of 5, print ‘bee’, if it is a multiple of both, print ‘foobee’

by the time you graduate from Coding Dojo, you shouldn’t have a problem doing those.

in terms of technical questions, most of them were java related. the ones i can remember are:

1) (java) what is the difference between overriding and overloading a method

2) whats the difference between strictly typed and loosely typed languages

3) (java) whats the difference between a hashmap and a hashtable

4) why would you enclose your entire javascript code/file in an anonymous function

5) what is an anonymous function


that’s pretty much all i can remember for questions. i felt like most of the conversation was basically throwing out names and them trying to understand if i was able to follow it. obviously they understood that i was a junior level developer, so nothing was too difficult, but if they got the impression that you could understand the basic technologies that they were using, it seemed to go over pretty well.

in terms of actually getting into interviews, I posted my resume on Monster and another website for more government related jobs. it seems like the Monster jobs were generally contract-to-hire, and you’d first speak with the recruiter (who would give you a call), who would run through and see if you can speak to the general buzzwords in their job description. then you would speak with their supervisor, and they would schedule an interview for you. i actually don’t think i got very many actual interviews from them, and the few i did were phone interviews which went not very well.

where i really started making progress was on the other government related website. if you are not looking for government contracting jobs, then this wouldn’t be good, but the recruiters from this site generally were calling on behalf of the company who was a prime or sub on the contract, and were looking for bodies to fill the empty slots. with them, i was able to get interviews very quickly. to give you an idea for the timeframe, i posted my resume to this site on tuesday, and had done two interviews, scheduled 3 more, and received an offer by friday.

once i had an offer in hand, recruiters jumped through hoops to make sure they could get an interview in with me before i accepted the existing one.  by the end of the next week, id gone on 7 or so more interviews, and received another 5ish offers. the point of this is making sure to be all like ‘hey you look like you have great stuff going on there, but i do have another offer that i am considering, so id appreciate it if you would be able to make the interview and decision happen before the end of the week’.

so thats all i can think of for now… but here is a recap:

  1. make it sound like everything you’ve done like has brought you to this point, and make it look like the level of experience that you are at has been enough to make you a functional developer.
  2. dont worry about algorithms, you all probably can do them
  3. pick a language, or not… well not sure on that. learn all of the languages. yep
  4. use your offer letter to make people move faster
  5. keep learning
  6. have fun
  7. good luck
  8. if i think of anything else ill make another post
  9. thanks