From: Stefan v. d. W. <st...@su...> - 2006-08-30 14:52:01
|
On Tue, Aug 29, 2006 at 03:46:45PM -0700, Mathew Yeates wrote: > My head is about to explode. >=20 > I have an M by N array of floats. Associated with the columns are=20 > character labels > ['a','b','b','c','d','e','e','e'] note: already sorted so duplicates=20 > are contiguous >=20 > I want to replace the 2 'b' columns with the sum of the 2 columns.=20 > Similarly, replace the 3 'e' columns with the sum of the 3 'e' columns. >=20 > The resulting array still has M rows but less than N columns. Anyone?=20 > Could be any harder than Sudoku. I attach one possible solution (allowing for the same column name occurring in different places, i.e. ['a','b','b','a']). I'd be glad for any suggestions on how to clean up the code. Regards St=E9fan |