# 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: Auction Solution

This code appeared in the Facebook Hacker Cup 2012 – Qualification Round You have encountered a new fancy online auction that offers lots of products. You are only interested in their price and weight. We shall say that product A is strictly preferred over product B if A costs less than B and is not […]

# Facebook Hacker Cup 2012: Billboards Solution

This code appeared in the Facebook Hacker Cup 2012 – Qualification Round We are starting preparations for Hacker Cup 2013 really early. Our first step is to prepare billboards to advertise the contest. We have text for hundreds of billboards, but we need your help to design them. The billboards are of different sizes, but […]

# 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 […]

# Facebook Hacker Cup 2011: Double Squares

Facebook Hacker Cup 2012 starts later today, so I am warming up trying to solve last year’s problems. Here’s the first one: A double-square number is an integer X which can be expressed as the sum of two perfect squares. For example, 10 is a double-square because 10 = 32 + 12. Your task in […]

# 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 […]