Ducci Sequence - Programming challenge [Java]
There was a challenge, it went like this: A Ducci sequence is a sequence of n-tuples of integers, sometimes known as "the Diffy game", because it is based on sequences. Given an n-tuple of integers (a_1, a_2, ... a_n) the next n-tuple in the sequence is formed by taking the absolute differences of neighboring integers. Ducci sequences are named after Enrico Ducci (1864-1940), the Italian mathematician credited with their discovery. Some Ducci sequences descend to all zeroes or a repeating sequence. An example is (1,2,1,2,1,0) -> (1,1,1,1,1,1) -> (0,0,0,0,0,0). I did this: import java.util.ArrayList; public class ducci_sequence { public int calculate(int[] sS) { ArrayList<String> pS = new ArrayList<String>(); String t = ""; for (int i = 0; i < sS.length; i++) t = ...