Bits of Discovery

Stuff I Like to Learn About

I Interned at a YC Company and You Should Too

I just got back from interning at Mattermark, which is a company that offers data and analytics to help answer a wide range of business questions. It’s especially useful for investors, and it turns out that almost every major VC you’ve heard of uses Mattermark for their own research and fact-finding. It was also formerly Referly, a business that got a good deal of attention when it launched a few years ago. When Referly was shut down, Mattermark was its pivot.

When I started interning there, of course, I knew none of this. In fact, I hardly had a clue about what a “Series” was, or why mythical beings like Angels were taking a keen interest in the startup world. I’m just a kid who likes to code and was looking for something interesting to do over the summer. What I got, apart from a really fun summer, was the chance to experience the business side of startups, through the lense of a rapidly growing startup from arguably the best startup incubator in the world. My horizons were broadened considerably, and I left with the impression that interning at a YC backed company is an opportune choice for any young programmer that shouldn’t be missed. Google and Facebook will still be around when you graduate, but being in the midst of a company at the crux of building a real foothold and exploding in growth is something you should be try to be a part of.

When you take up an internship at a startup, it’s decidedly low risk. It doesn’t involve the same leap of faith as the full timers there, who have accepted the potential risk of the company failing and being out of a job. Being a student and short term employee, the risk just isn’t the same, and the upside is huge. For example, I was employee(technically) #17 or so at Mattermark. If (when!!) it gets huge, that would be a huge point of pride for me and something I might not have a chance at again. To drive this point home, just during my time at Mattermark, the company had grown to around 25 people. That’s how quickly things change.

Another cool thing about being at startup that really embraces the role is that you get to do, as Paul Graham put it, things that don’t scale. This idea extends to a lot of different things but it manifested itself to me in a number of ways. Firstly, I was able to have weekly sitdowns with the CTO of the company and discuss the progress I was making and if I was facing any roadblocks. Being able to interface like that with the leadership of a company is something you just can’t do at larger companies. Another thing we got to do was go to Dillon Beach for a month and work from there. Even at the scale we had at the time, I could tell it just wouldn’t be very feasible with a team any larger than what we had. Earlier in the summer, we organized a mock VC pitch with real investors where we invited a few to the office and each employee pitched a company they had spent some time researching. Superficially this event had no real impact but, in candid discussions with the investors, I got some great insight into what kind of signals investors pay attention to.

A great thing about interning at a YC company specifically is going out and meeting all the brilliant people in the YC network. This includes founders, interns, and employees alike. Near the beginning of my internship I was invited to a barbeque at the YC headquarters in Mountain View. In just the span of a few hours I had met and even started bonding with a bunch of really smart, talented, motivated people. In fact it might have been one of the highest density gatherings of smart people I had ever been a part of. I met tons of interns, and in talking to them I got a broader and better understanding of what motivates kids who are in the same phase of life and profession as me. Not to mention, I got to chat with key people at YC and, if I develop entrepreneurial hopes down the line, I have something to introduce myself with (“I was the intern for Mattermark who chatted with you about ___ at the Intern BBQ…”)

Even if you have no desire to start a company, you should go after an opportunity to see a growing company from the inside. You should pay close attention to how the founders make decisions, and how those decisions impact all aspects of the business. You should have practice talking to people about a not-hugely-known company and getting them hooked on it’s mission and the impact it’s going to have. You should live, at least vicariously, the life of a startup and, potentially, be in the middle of something huge.

My First Raspberry Pi Project

So last week I got my Raspberry Pi in the mail, and since the World Cup has rolled around again I decided to create a World Cup scoreboard as my first project. Since I’ve had no previous experience with circuitry and GPIOs beforehand it was quite a gratifying learning experience for me. I was disproportionately happy when I first completed a circuit and lit up a little red LED. I ordered a starter kit so I had a breadboard, LEDs and jumper wires right off the bat. The basic concept is pretty simple. I poll an API every minute (originally I was just scraping ESPN) and light up the scoreboard according to how many goals had been scored on either side. I also programmed a special lighting sequence everytime a goal was scored as a sort of visual cue/celebration. The lights I used are pretty standard single color LEDs and the resistors were 330 ohms. I wired each light with a resistor so the lights wouldn’t burn out and used all of the 8 general purpose pins on the pi, one for each light. Unfortunately that doesn’t allow for all possible game scores but I could have done it in binary if I felt like it (which would defeat the convenience of the whole thing). In any case, here is a picture and the source code! I made it to be callable from the command line:

1
$ python scoreboard.py Germany Argentina

My Hackathon Experience

So I attended the UWaterloo Hackathon the other night and it was a rereally neat experience. There were a ton of people there, and some folks came down from Google Waterloo to help out with judging and mentoring.

As for my personal project, I decided to make an attempt at solving a problem I face a lot in my personal life. I have a practice of sending my close friends lots of links over facebook and other mediums. Sometimes, my friends are too busy to look at it right then and there. But later, when I ask them about the link to discuss it with them, the link is somewhere up in the conversation thread and it becomes too much of a hassle to retrieve it again. That’s where CheckIt comes in. My goal is to allow friends to send each other links in a private way, so that when they log in, they see your links displayed in chronological order so they can catch up on anything you left them. I’m also planning to allow the user to leave a quick comment on the link, expressing how they feel about it. This summer I plan to integrate with facebook so that whenever a link is sent in your chats, CheckIt can just ship it off to your account so that you can read it later whenever you want.

You can CheckIt right now although the functionality is pretty bare. Next on my list of improvements is better routing, autocomplete for link recipients, and being able to send “friend requests” so you can approve who you’ll get links from.

2048 Mod

So the 2048 craze has pretty well taken hold, so I decided to make a little mod myself out of it. The idea is that every 10 seconds, everyone playing accept everyone else’s keystrokes for a brief moment. I did this using Socket.io along with Node.js to send movements across clients. The main bit of code on the server involves adding and removing the event listener the appropriate intervals:

1
2
3
4
5
6
7
8
9
10
var cb = function (direction) {
  socket.broadcast.emit('keypress', direction);
};

setInterval(function () {
  socket.addListener('keypress', cb);
  setTimeout(function () {
    socket.removeListener('keypress', cb);
  }, 100);
}, 10000);

I also added a display so you can know how many other players are online! You can check it out here.

Wildcard Programming Challenge

I came across a neat programming question at a tech company called WildCard and decided and I’d take a crack at it in C. The idea here is pretty simple using some basic combinatorics. If you have fewer than 5 available spots in any given row/column, clearly you can’t place 5 cards there. However, if you have >= 5 open spots, you can do the following: place the cards in (EmptySpots choose 5) places, and once you’ve placed them there, you can shuffle the cards in those 5 places in 5! ways. So when you multiply these together you get the number of possibilities for a single row or column. All we have to do now is iterate over the table and sum these values up! Here’s the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define TABLE_SIZE 50
#define NUM_CARDS 5

int fact(int n){
  int i;
  for(i=n- 1; i>0; i--){
    n *= i;
  }

  return n;
}

int nck(int n, int k){
  if(n < k) {
    return 0;
  }
  else if(n == k) {
    return 1;
  }
  int sol = fact(n) / (fact(k) * fact(n-k));
  return sol;
}

int main(){
  char ch;
  FILE *fp = fopen("problem1input.txt", "r");

  int cols[TABLE_SIZE];
  memset(cols, 0, TABLE_SIZE * sizeof(int));

  int answer = 0;
  int num_empty = 0;

  int i;
  int j;

  for(i = 0; i < TABLE_SIZE; i++){
    for(j = 0; j < TABLE_SIZE; j++){
      fscanf(fp, "%c", &ch);
      if (ch == '*') {
        cols[j]++;
        num_empty++;
      }
    }
    fscanf(fp, "%c", &ch);
    answer += nck(num_empty, NUM_CARDS);
    num_empty = 0;
  }
  fclose(fp);

  for(j = 0; j < TABLE_SIZE; j++){
    answer += nck(cols[j], NUM_CARDS);
  }

  //120 is the number of ways I can arrange the 5 cards in 5 spots, ie 5!
  printf("%d\n", answer * 120);
  return 0;
}

And if you’re interested in the answer, there are a whopping 167,160 ways to do this! Crazy how numbers work.

Levenshtein Distance

I was reading on wikipedia about a few string functions and one interesting one that I came across is the Levenshtein Distance. It’s a really neat way of figuring out the “edit distance” between two strings, and, like many problems, it’s best stated recursively. So here’s my implementation in racket. It’s always interesting to think about how some problems almost beg to be solved via a particular paradigm, and I think this is one of them. For comparison, the imperative solutions on the wiki page are quite long and a bit unwieldy.

1
2
3
4
5
6
7
8
9
10
11
(define (reallev str1 str2)
  (define cost 0)
  (cond [(empty? str1) (length str2)]
        [(empty? str2) (length str1)]
        [else
           (when (not (equal? (first str1) (first str2))) (set! cost 1))
           (min (add1 (reallev (rest str1) str2))
                (add1 (reallev str1 (rest str2)))
                (+ (reallev (rest str1) (rest str2)) cost))]))

(define (lev str1 str2) (reallev (string->list str1) (string->list str2)))

Some cool uses of this might be, for example, to suggest spelling corrections on devices. If you misspell a word, chances are the one you want is a short number of edits away, which in this algorithm is formalized as being either a insertion, deletion or replacement.

The gist of the algorithm is quite simple. You start off comparing the strings pairwise. As seen in the recursive call at the end of a function, if the two characters being compared do not match, you’re trying to achieve the minimum of of the 3 strategies by attaching a “cost” to each operation and allowing each scenario to be recursed upon. It’s quite elegant, and to me it turned out to be simpler than I assumed it to be.

Sieve of Eratosthenes

So I’ve been taking an interest in prime numbers recently and how to generate them, so I wrote a up a quick implementation of The Sieve of Eratosthenes in Python. Here it is:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
def primes(n):
  candidates = []
  for i in range(2, n+1):
    candidates.append([i, False])
  p = 2
  sieve(candidates, p)

def sieve(candidates, p):
  done = False
  while(not done):
    for pair in candidates[p-2::p][1:]:
      pair[1] = True

    found = False
    rest = candidates[(p-2):][1:]
    for pair in rest:
      if not pair[1]:
        p = pair[0]
        found = True
        break

    if not found:
      done = True

  for pair in candidates:
    if not pair[1]:
      print pair[0]

For those interested in more curious facts about prime numbers a brilliant talk is given by the great Terrence Tao. It’s a bit lengthy but well worth your time.