Link

I’m sitting in Starbucks, sipping on a strawberry smoothie that’s slightly satisfying, though not as much as it first appeared to be. This week’s been good. For the uninitiated, I’m spending my summer in Seattle, working at StockCharts.com (no prizes for guessing what they do), a software company based in Redmond, Washington. I managed to come by this opportunity earlier in the semester, and I jumped at it – getting real world experience coding is something I’ve been meaning to do for a while, and this opportunity seemed perfect.

This week’s been interesting in many ways. Coming in, I was under the impression that we would be spending the first few weeks going through the basics of Java and learning how to write proper code in Java, which I have some cursory experience with. However, since this class of interns is the most qualified that the company has had, we had a different path set for us. We blazed through everything in Java over this last week, learned a lot about how companies work and the technologies they use. We learned a lot besides Java, but since the company runs on Java code, the major part of our week went towards learning Java and techniques and designs that go with it.

We reviewed a lot of code that the company ran on, as well as projects that past interns and employees worked on, which gave us an idea of what proper code looks like. Chip, the CEO of the company (and by extension our boss), went through all the code with us, and pointed out what made the code good, and on occasion, what made it bad. Through all this, we were also given a few coding assignments, of which one stuck out to me – the random number generator.

Random Number Generator

Chip, in his infinite wisdom (or almost infinite, the man’s a genius), decided that the first assignment we were to have was to somehow prove that the random number generator built into Java wasn’t exactly random. A quick Google search shows that this is true, it is actually just a pseudorandom number generator – the formula it uses to update the seed for the numbers is

 (seed * 0x5DEECE66DL + 0xBL) & ((1L << 48) - 1)

and it goes on to return

 (int)(seed >>> (48 - bits)).

We spent hours on this, trying to figure out methods to prove that it wasn’t actually random. We printed buckets of data, tried calculating averages and printed out massive amounts of numbers trying to figure out ways to prove it, but we came up with nothing. The next day, after seeing our solutions, Chip explained to us that there wasn’t exactly a proper way to prove that it wasn’t random, unless you were able to set the seed yourself. He told us that this was mere pedantry, and for all practical purposes, a lot of things that aren’t going to be exactly what we need them to be, but they don’t have to be for them to work. A pretty cool way to teach something, if you ask me.

All in all, it’s been a great week. The company’s great, and I can see myself getting very well acquainted with the drinks fridge employees over the summer. I’ve learned more over this five day period than I have over any other five day period in my life, and it’s only been a week. I’m excited to see what the rest of the summer has in store!

Peace, Love and Algorithms

Rajesh Narayan

Leave a Reply

Your email address will not be published. Required fields are marked *