【发布时间】:2012-01-23 22:38:40
【问题描述】:
谁能给我一些代码或算法或其他东西来解决以下问题? 我有几个文件,每个文件都有不同的列数,例如:
$> cat file-1
1 2
$> cat file-2
1 2 3
$> cat file-3
1 2 3 4
我想减去列的绝对值并除以每个不同列的一行中所有的总和一次(没有重复列对的组合):
in file-1 case I need to get:
0.3333 # because |1-2/(1+2)|
in file-2 case I need to get:
0.1666 0.1666 0.3333 # because |1-2/(1+2+3)| and |2-3/(1+2+3)| and |1-3/(1+2+3)|
in file-3 case I need to get:
0.1 0.2 0.3 0.1 0.2 0.1 # because |1-2/(1+2+3+4)| and |1-3/(1+2+3+4)| and |1-4/(1+2+3+4)| and |2-3/(1+2+3+4)| and |2-4/(1+2+3+4)| and |3-4/(1+2+3+4)|
【问题讨论】: