Langton's ant is a cellular automaton that models an ant sitting on a plane of cells, all of which are white initially, facing in one of four directio
Continue ReadingC++: Loop Continue
Show the following output using one loop. 1, 2, 3, 4, 5 6, 7, 8, 9, 10 Try to achieve the result by forcing the next iteration within the loop up
Continue ReadingC++: Longest Common Subsequence
#include <algorithm> #include <string> #include <vector> #include <stdio.h> #include <string.h> // See http
Continue ReadingC++: Call a Foreign-Language Function
Show how a foreign language function can be called from the language. As an example, consider calling functions defined in the C language. Create a
Continue ReadingC++: Catamorphism
Reduce is a function or method that is used to take the values in an array or a list and apply a function to successive members of the list to produce
Continue ReadingC++: Comma Quibbling
Comma quibbling is a task originally set by Eric Lippert in his blog. The task is to write a function to generate a string output which is the conc
Continue ReadingC++: Dijkstra’s Algorithm
Dijkstra's algorithm, conceived by Dutch computer scientist Edsger Dijkstra in 1956 and published in 1959, is a graph search algorithm that solves the
Continue ReadingC++: Dutch National Flag Problem
The Dutch national flag is composed of three coloured bands in the order red then white and lastly blue. The problem posed by Edsger Dijkstra is:
Continue ReadingC++: Standard Error
A common practice in computing is to send error messages to a different output stream than normal text console messages. The normal messages print
Continue ReadingC++: Identity Matrix
Build an identity matrix of a size known at runtime. An identity matrix is a square matrix, of size n × n, where the diagonal elements are all 1s,
Continue Reading




