Permutations with awk

Hello I have a very simple input file in which there are a list of numbers:

1
2
3
4
5
6
7
8
9
10

My actual dataset is about 200 lines long. I was wondering how to add different permutations of 3 numbers for all the numbers in the dataset. For example:
1+2+3; 3+5+7; 2+8+1; 9+3+4 etc...

I have no idea on how to go about this. Any help would be appreciated.

A trivial way to get all n*n*n combinations of three things listed in an n line file using awk is:

awk '
{	a[$0]
}
END {	for(i in a)
		for(j in a)
			for(k in a)
				print i, j, k
}' OFS=, file

For a 200 line file, that is 8,000,000 combinations.

If, as in your example, there aren't any spaces in your input files, you can omit the OFS=, to use space as the field separator in your output. If there are commas and spaces in your input, pick another output field separator.

As always, if you want to try this on a Solaris/SunOS system, change awk to /usr/xpg4/bin/awk , /usr/xpg6/bin/awk , or nawk .