I have a textfile with an arbitrary number of rows, triplets like these:
4 5 2
12 16 6
Now I want to add related rows to the file. Let's say I want to add 4 additional rows per row which have similar values. The first two columns are slightly altered (-1 and +1 for exactly one of them, all four combinations) and for the third column the value is halved:
4 5 2 (original row)
3 5 1 (added rows)
5 5 1
4 4 1
4 6 1
12 16 6 (original row)
11 16 3 (added rows)
13 16 3
12 15 3
12 17 3
It does not matter where the rows are appended, so it's OK if the added rows are all at the end of the file.