list to table

Scott David Daniels Scott.Daniels at Acm.Org
Thu Nov 5 10:33:40 EST 2009


jay wrote:
> ...
> I have a long list of data of associations between values with a value
> to that association as follows...
> A B 1
> B A 1
> ... And need to build a table as follows that accumulates the above:
> 
> row is (from)
> column is (to)
> 
>    A B C
> A 0 4 7
> B 4 0 0
> C 2 0 0
> 
> Just can't seam to figure out how to manage this programatically.

How to solve this:  Define (quite carefully) what you mean by
"build a table" for yourself.  Then, determine a single step
that either gets you closer to the answer (going forward) or
(working backward) determine something (typically some data
structure) that you could use to produce the result you need.
Keep pushing at both ends until you can get them to meet in
the middle.

--Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-list mailing list