Category Archives: C++

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

Using the Built-in Sort and Search Functions in C++

Being able to implement your own versions of quicksort (as well as other sorts that might be suitable for the occasion) and binary search algorithms is important (you can check my own implementations here). However, when you are participating in programming contests and challenges the last thing you want to worry about is whether or […]

Generating Permutations in C++

Suppose you have the following set: {0,1,2}. How do you generate all the possible permutations of such set? One possible approach is to use recursion. First we need to break the problem into smaller sub-problems. This could be done by splitting the set into two parts. We keep the right side fixed, and then find […]

Powerset Algorithm in C++

A powerset of a given set is the combination of all subsets, including the empty subset and the set itself. Suppose we have the following set: {1,2,3}. Its powerset would be: {1,2,3} {1,2} {1,3} {2,3} {1} {2} {3} Creating an algorithm to generate a powerset is not trivial. The first idea you can use is […]