Welcome to the Monastery | |
PerlMonks |
Re: Table shuffling challengeby code-ninja (Scribe) |
on Aug 24, 2013 at 06:43 UTC ( [id://1050773]=note: print w/replies, xml ) | Need Help?? |
ok, I'm at my work place so cannot submit the code right now but I'll post my algorithm at least because my boss is not around and this post got me ticking... ;). I'll upload my rendition of the code once I get home. A Sparse MatrixA matrix populated mostly with 0s (or null for objects) is called a sparse matrix. Refer this. Keeping this in mind and re-reading your question, I can represent your data as a sparse matrix (critical analysis of this assumption is welcome). To parse a sparse matrix, my algorithm is as follows:
The algorithm essentially creates a 3-tuple (row, column, value) and using a hash makes random access faster as compared to arrays. The wiki link above elucidates more algorithms to represent a sparse matrix.
In Section
Seekers of Perl Wisdom
|
|