[TAG] Max-spread algorithm

Neil Youngman ny at youngman.org.uk
Thu Jul 5 19:54:21 MSD 2007


On or around Thursday 05 July 2007 16:08, Ben Okopnik reorganised a bunch of 
electrons to form the message:
> On Thu, Jul 05, 2007 at 03:26:53PM +0100, Neil Youngman wrote:
> > Yeah. I didn't really make the mixing of integers and floating point
> > numbers clear enough. Variables toms_in_gap  and toms_used were always
> > meant to be integers :-) Would something like
> >
> >   toms_in_gap[g] = round(((g+1) *fill) - toms_used);
> >
> > fix it?
>
> I don't have a 'round', but I can use a 'floor' ("largest integer value
> less than or equal to the argument) - I think it's what you mean. That
> one requires the POSIX module, which just happens to be part of Perl.

floor isn't quite the same as round, e.g. floor( 0.9 ) != round( 0.9 ). You 
can use floor to simulate round

float round( float x )
{
  return floor( x+0.5 );
}


>
> This is fun! :) Although when I try to figure out how you came up with
> that algorithm, it's a dark, impenetrable forest to me. You math people
> are amazing; I wish I spoke the language.

It's just a question of figuring out the average number of tomatoes you need 
in each gap and then dealing with the problem that you can't actually slice 
them up. There's nothing in there that I would call deep math. All the fancy 
crypto stuff loses me in no time flat.

Neil




More information about the TAG mailing list