I have a data file looks like :
1 1 1 1 1 1 1 1 2 2 2 2 3 3 3 3 3 3
2 4 5 8 9 10 13 17 19 29 30 32 33 50 700 800 900 950
first I want to insert space among each 3 identical values keeping each three identical numbers together in one colum by looking at the first row :
1 1 1 1 1 1 1 1 2 2 2 2 3 3 3 3 3 3
2 4 5 8 9 10 13 17 19 29 30 32 33 50 700 800 900 950
and then I want to subtract the first value from the last one within each new column at second row ( but if there was only one value at a specific column(here the forth column at second row), then the last value from the previous column should be subtracted from that value(32-30)) while keeping one unique number out of each column from the first row. so the final data should be like this:
1 1 1 2 2 3 3
3 2 4 11 2 667 150
any suggestion please? meanwhile I should mention my real data is indeed huge and I want to group each 5 unique values at first row. I may want to change the size of group . So I need the script to be flexible ..