Each time you find another good 9-mer, you add it to the head of the list. This means that the ultimate list will be in reverse order of discovery: the first element to be printed is the last one to be found. To get output in the order it was discovered, build the output by ys++[y] rather than y:ys.