[Gllug] OT: algorithm needed
salsaman at xs4all.nl
salsaman at xs4all.nl
Sun Aug 10 20:33:30 UTC 2008
Hi,
here is one for the maths lovers.
I am trying to devise an algorithm to read in blocks from disk. There is a
total read size, and a max block size.
On each read I read in max_block_size or less bytes, until the total is
reached.
However, I want the last read to be as close to max_block_size as possible.
E.g. if total==100, max==45, I could read:
45, 45, 10.
However it would be preferable to read:
40, 40, 20, or better yet:
35, 35, 30
Also, I want to do this without pre-calculating, i.e the next block size
must be calculated from total and max.
Any ideas ? Is there a simple algorithm to do this ?
Gabriel.
http://lives.sourceforge.net
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list