Chess960 is a variant of chess created by world champion Bobby Fisher. Unlike other variants of the game, Chess960 does not require a different materi
Continue ReadingC++: Greatest Common Divisor
This task requires the finding of the greatest common divisor of two integers. Copied from least common multiple page for the sake of completeness.
Continue ReadingC++: Knuth’s Algorithm S
This is a method of randomly sampling n items from a set of M items, with equal probability; where M >= n and M, the number of items is unknown unt
Continue ReadingCppCon 2014: Herb Sutter “Back to the Basics! Essentials of Modern C++ Style”
https://www.youtube.com/watch?v=xnqTKD8uD64
Continue ReadingC++: Execute a System Command
In this task, the goal is to run either the ls (dir on Windows) system command, or the pause system command. Works with: Visual C++ version 2005 sys
Continue ReadingC++: Horner’s Rule for Polynomial Evaluation
A fast scheme for evaluating a polynomial such as: when . is to arrange the computation as follows: And compute the result f
Continue ReadingC++: Input Loop
Read from a text stream either word-by-word or line-by-line until the stream runs out of data. The stream will have an unknown amount of data on it.
Continue ReadingC++: Knapsack Problem
A tourist wants to make a good trip at the weekend with his friends. They will go to the mountains to see the wonders of nature, so he needs to pack w
Continue ReadingC++: Sort a Range of Elements
On line 8, we create a std::array of ints that we wish to sort. On line 10, we call the standard alrogithm std::sort, which sorts the range of elem
Continue ReadingC++: Swap Values
On lines 6–7, we create two std::string objects whose values we wish to swap. However, this sample will also apply to any other swappable type. O
Continue Reading




