A program was given 5 input sequences. As a result it generated the following web page. Each section contains the original input repeated and a small JavaScript code which allows to see further elements of the sequence.
Here is a short explanation of the sequences:
- Difference between elements is increasing
- Quotient of elements is -0.5
- Sequence of sequences. After a rule was found for one subsequence - it is tried against other subsequences to find analogy. The intermediate steps is a sequence of analogical formulas. Finally a master formula is found.
- Simliar to 3 but the formulas of internal sequences are more complicated
- AI tries to transform strings to sequence of characters which are then translated into numbers taking position in alphabet of each letter. A reverse transformation is made when displaying the results.
Generated code
Let's take a look at the body of this page. For each consecutive inputs AI generates function starting with name "riddle" which outputs sequence given its length. The code uses some human-programmed functions (for example those starting with seqOf...) stored in a separate .js file. Its content may be seen here.
[1, 2, 4, 7]
/**
* Returns extension of sequence [1, 2, 4, 7]
* @param listSize Size of generated sequence
*/
function riddle1 (listSize) {
var tmp1 = function(i,tab) {
return tab[i-1]+tab[i-1]-tab[i-2]+1;
};
return listGen(
listSize,tmp1,
[1, 2]) /* [1, 2, 4, 7] */;
}
[16, -8, 4, -2]
/**
* Returns extension of sequence [16, -8, 4, -2]
* @param listSize Size of generated sequence
*/
function riddle2 (listSize) {
return listGen(
listSize,
function(i,tab) {
return tab[i-1]*-0.5;
},[16]) /* [16, -8, 4, -2] */;
}
[[1, 2, 3], [1, 3, 5], [1, 4, 7]]
/**
* Returns extension of sequence [[1, 2, 3], [1, 3, 5], [1, 4, 7]]
* @param listSize Size of generated sequence
*/
function riddle3 (listSize) {
var tmp1 = listGen(
listSize,
function() {
return 1;
}) /* [1, 1, 1, 1] */;
var tmp2 = listGen(
listSize,
function(i,tab) {
return tab[i-1]+1;
},[2]) /* [2, 3, 4, 5] */;
var tmp3 = listGen(
listSize,
function(i,tab) {
return tab[i-1]+2;
},[3]) /* [3, 5, 7, 9] */;
return seqOfStruct(tmp1,tmp2,tmp3) /* [[1, 2, 3], [1, 3, 5], [1, 4, 7], [1, 5, 9]] */;
}
[[1], [3, 6], [5, 10, 20]]
/**
* Returns extension of sequence [[1], [3, 6], [5, 10, 20]]
* @param listSize Size of generated sequence
*/
function riddle4 (listSize) {
var tmp3 = listGen(
listSize,
function() {
return listGen;
}) /* [LIST_GEN, LIST_GEN, LIST_GEN, LIST_GEN] */;
var tmp4 = listGen(
listSize,
function(i,tab) {
return tab[i-1]+1;
},[1]) /* [1, 2, 3, 4] */;
var tmp1 = function() {
return function(i,tab) {
return tab[i-1]*2;
};
};
var tmp5 = listGen(
listSize,tmp1) /* [{a[n-1]*2}, {a[n-1]*2}, {a[n-1]*2}, {a[n-1]*2}] */;
var tmp2 = listGen(
listSize,
function(i,tab) {
return tab[i-1]+2;
},[1]) /* [1, 3, 5, 7] */;
return evalSeqOfCall(tmp3,tmp4,tmp5,
seqOfStruct(tmp2) /* [[1], [3], [5], [7]] */) /* [[1], [3, 6], [5, 10, 20], [7, 14, 28, 56]] */;
}
[B, D, F]
/**
* Returns extension of sequence [B, D, F]
* @param listSize Size of generated sequence
*/
function riddle5 (listSize) {
var tmp1 = function(i,tab) {
return numberToBigLetter(
bigLetterToNumber(
tab[i-1])+2);
};
return listGen(
listSize,tmp1,
['B']) /* [B, D, F, H] */;
}
Used functions
The above code is fully generated but it uses some human-programmed functions stored in a separate .js file. Its content may be seen here.