Floyd's triangle lists the natural numbers in a right triangle aligned to the left where the first row is just 1 successive rows start towards
Continue ReadingC++: Infinity
Write a function which tests if infinity is supported for floating point numbers (this step should be omitted for languages where the language specifi
Continue ReadingC++: Input/Output for Pairs of Numbers
From lines of input starting with a line containing the numbers of pairs to follows, followed by that number of pairs of integers separated by a space
Continue ReadingC++: Execute Only Part of Loop
Quite often one needs loops which, in the last iteration, execute only part of the loop body. The goal of this task is to demonstrate the best way to
Continue ReadingC++: LZW Compression
The Lempel-Ziv-Welch (LZW) algorithm provides lossless data compression. You can read a complete description of it in the Wikipedia article on the sub
Continue ReadingWhat is “:-!!” in C code?
I bumped into this strange macro code in /usr/include/linux/kernel.h: /* Force a compilation error if condition is true, but also produce a resul
Continue ReadingC++: Longest Common Substring
#include <string> using std::string; int LongestCommonSubstring(const string& str1, const string& str2) { if(str1.empty() |
Continue ReadingC++: Binary Search
//! \brief A recursive binary search using STL vectors //! \param vec The vector whose elements are to be searched //! \param start The index of
Continue ReadingC++: Digital Root
The digital root, X, of a number, n, is calculated: find X as the sum of the digits of n find a new X by summing the digits of X, repeating un
Continue ReadingC++: Generate Chess960 Starting Position
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 Reading




