Monthly Archives: January 2012

MySQL Basic Commands

Below you’ll find some basic MySQL commands in case you are new to it. First of all I recommend using the MySQL terminal to connect to your database server, because it forces you to learn the commands by hand. Using a GUI tool like PHPMyAdmin makes the job easier but removes the learning curve. I […]

Facebook Hacker Cup 2012: Alphabet Soup Solution

This code appeared in the Facebook Hacker Cup 2012 – Qualification Round Alfredo Spaghetti really likes soup, especially when it contains alphabet pasta. Every day he constructs a sentence from letters, places the letters into a bowl of broth and enjoys delicious alphabet soup. Today, after constructing the sentence, Alfredo remembered that the Facebook Hacker […]

Facebook Hacker Cup 2012: Qualification Round

This past weekend the Facebook Hacker Cup 2012 took place. I found it was very well organized, and everything was working fine, including the submissions and the scoreboard. If you haven’t participated this year, I highly recommend you do so next year. The qualification round consisted of 3 problems, and any participant solving at least […]

CodeSprint 2 Problem: Subsequence Weighting

Another problem from CodeSprint 2: A subsequence of a sequence is a sequence which is obtained by deleting zero or more elements from the sequence. You are given a sequence A in which every element is a pair of integers i.e A = [ (a1, w1) , (a2, w2) ,…,(aN, wN)]. For a subseqence B […]

CodeSprint 2 Problem: How Many Coin Tosses to Get N Heads?

I am participating in InterviewStreet’s CodeSprint this weekend. It’s basically a 48-hour coding competition. Some of the problems are quite interesting, and I’ll be talking about them here. The first one I tried had this description: You have an unbiased coin which you want to keep tossing until you get N consecutive heads. You’ve tossed […]

Simple Poker Game in C++

I started studying C++ and Object Oriented Programming recently, so I decide to create a small poker game, Texas Hold’em style. It took me three days and 670 lines of code, which I don’t think is too bad given it simulates a complete poker game for one human player against 5 computer players. The fact […]

A Better Poker Hand Evaluator in C++

Still working on my poker game simulation, and now I got to the hand evaluation part. I had written a small C program to do it a while ago, but taking a look at it now, well, all I can say is it was pretty awful. I didn’t sort the cards on that program, so […]