Intro
Yesterday, I took a trip down to Columbia, MD for a job interview. Columbia is a great little area (at least from the parts I saw and the reviews I have read, that seem to continually rank it among the United States' top 10 best places to live.) The actual trip was quite a disaster, but the interview went rather well. We'll see what happens; I've got my fingers crossed.
How Not to Implement a Linked List
I'm sure everyone who would be interested in reading this would also be smart enough to not do this, but you never know. I thought I was smart enough to not do this. Please don't laugh too hard.
So here I am, interviewing, thinking everything is going well, and then it's time for the whiteboard implementation of a linked list insert routine. I seriously wrote this:
struct list {
int data; /* whatever payload our list is carrying */
struct list *next;
};
void list_insert(struct list *head, int payload) {
struct list *tmp, *tmp2;
tmp = head;
while (tmp && tmp->next != NULL) {
tmp = tmp->next;
}
tmp2 = malloc(sizeof (struct list));
/* err... yeah, skipping out on error checking here */
tmp2->data = payload;
tmp2->next = NULL;
tmp->next = tmp2;
}
Yeah, it works, but that's not the point. It doesn't work well. Comments are things I mentioned amidst writing it out. But I also, while writing while on the whiteboard, had my brain kick in. Well, halfway. My brain said, ``Oh hello there, jolly ol' chap. That's not optimal. But I'll be damned if I'm telling you why!'' So here I am, with while (tmp && tmp- written up there, saying, ``Yeah, uh. This is by no means any kind of optimal.''But I couldn't figure out why.
Other than that, the interview went well, and I had a lot of fun. (Except for the travel, which was a nightmare, but an acceptable one.)
So I'm back on the train, heading up to New York, and all of a sudden it hits me. ``He said implement a linked list insert, not append.'' D'oh. Of course append *does* insert, but unless you're sorting or whatever... it's really useless.
Except I didn't have any way to do the quick post-interview email. I had just brought a book for the train, and I certainly wasn't going to ask any of these weird businessey-salesy-markety guys to borrow their laptop with its nifty 3G PCMCIA card. (``Why not,'' you may ask. Because my train was delayed for an hour, I wasn't going to be getting home until 2AM at the earliest, and I simply wasn't in the mood to interact at that point.)
Anyway, at the point that I did get home (at about 1:45AM, no less), I hopped on the computer and fired off an email. (I mean, seriously, who implements an O(n) linked list insert?) Instead, what you are supposed to do is insert at the head of the list:
struct list {
int data; /* whatever payload our list is carrying */
struct list *next;
};
void list_insert(struct list **head, int payload) {
struct list *tmp;
tmp = malloc(sizeof (struct list));
tmp->data = payload;
tmp->next = *head;
*head = tmp;
}
So, yeah. Go go brainiac me. Oh well, at least I was still awake enough to realize I needed the pointer to pointer to be able to change the list head.Fun with Amtrak
I quite possibly could have named this section Worst Train Ride in the History of Man, or possibly something a little less exaggerated, but less sarcastic. In that case, I'd simply modify the title to [I Did Not Have Any] Fun with Amtrak. Let me explain.
The actual travel itself was not so bad. In fact, I rather enjoy trains. I used to hop on them all the time when living in Holland, and so it's nice to see this manner of public transportation still have viable use here in the States. No, the travel itself was fine. But Amtrak has absolutely GOT to do something about their schedules.
Clocks, guys. Fix your Clocks
Amtrak's clocks are broken. Before you tell me that my clocks are broken, I'd like to remind you that I'm a geek, and I'm nutty about time. I'm the kind of asshole that ignores pastes including timestamps if it's somehow obvious that the timestamp is incorrect. By any verifiable amount of time. Not only that: if the timestamp includes a seconds part (my client doesn't show seconds), I'll go run date and determine whether that user actually is off by seconds.
So it should serve as no surprise for you to understand that when I walked into Amtrak at 4:55AM, and they said the 5:10 train had left, and their clock showed 5:12, I was pissed. Yeah, I can understand a car clock being off by a couple of minutes, since it's not the type of thing you look at fixing daily. But how the HELL do you get 15 minutes of drift?
Changing Tickets
Apparently when you change your tickets, any discounts applied to your old ticket doesn't apply to your new ticket. So the company interviewing me had purchased my ticket, and they put the AAA discount on the thing. Apparently they don't copy that over to any further transactions to make on your itinerary. So I paid $10 to change the couple tickets over to take the next train to NY Penn station, and then the train from there to Baltimore. And I took the next train, which was about an hour later, and got me in two hours later than I was originally going to be arriving.
Taxi Drivers in Baltimore are lol
They might know Baltimore, but ask them to go 10 miles out of it and they get lost. Having never been to the offices of this company, *I* had to guide the taxi driver. What a noob.
FIX YOUR GODDAMN TRAINS
Yeah, so... Amtrak? You remember how I said to fix your clocks? Fix your trains too, while you're at it please.
I get to the BWI station, and I was going to need to change over one of my tickets to make the 4:23 train at BWI (instead of the 4:34 train at Baltimore Penn) so that I could interview a few minutes longer and make it to the station on time. I got to the station on time, and I go in to change my tickets. But I'm in line, and I notice it hits 4:23, and there's no train.
Yeah. The 4:23 train was delayed an hour and a half. So instead of being able to take that train, I had to take the 5:33 train up to New York Penn. My connecting train up to Albany left at 8:34 or something. The 5:33 train would get me there at 8:37. (Seriously, what the fuck?) Oh, the best part: the next train to Albany after *that* left at 10:45 and didn't get to Albany until 1:15AM.
So, whatever. In the end, I ended up getting out at NY Penn, calling my girlfriend and she came and picked me up in the city. We got home at around 1:45AM, which was still sooner than we would have gotten home if I had taken the train up to Albany (though I suppose I should place that part of the blame on the fact that both of us live in the middle of nowhere.)
