The Five-Minute Forums

The Five-Minute Forums (http://www.fiveminute.net/forums/index.php)
-   Miscellaneous (http://www.fiveminute.net/forums/forumdisplay.php?f=10)
-   -   Pop quiz! (http://www.fiveminute.net/forums/showthread.php?t=482)

Nic Corelli 08-22-2004 03:03 AM

PHJ, Fuyu, Daniel and possibly some other people (can`t remember quite right) took my quiz and thought my real name was Carlos Armando! :mrgreen: :mrgreen: :mrgreen:

danieldoof 08-22-2004 08:39 AM

maybe it will get better when I hang around here a bit :wink:
I barely know you all yet

but my score is not bad for guessing is it?

PointyHairedJedi 08-22-2004 12:16 PM

Quote:

Originally Posted by Nic Corelli
PHJ, Fuyu, Daniel and possibly some other people (can`t remember quite right) took my quiz and thought my real name was Carlos Armando! :mrgreen: :mrgreen: :mrgreen:

GASP!

You mean it isn't? :shock:

catalina_marina 08-22-2004 09:29 PM

Thank you, Nic, for digging up this thread. For some reason I couldn't find it when I tried to, a week or so ago.

Quote:

Originally Posted by Michiel
Any idea how you would go about it if you had, say, 4 balls?

Or: More than two balls and not enough balls for a binary search?

One ball: 100 tries.
Two balls: 14 tries.
Three balls: 9 tries.
Four balls: 8 tries.
Five or more balls: 7 tries.

Now, please don't ask me to generalize it further, for another number other than 100 stories, so that I'd actually have to set up a formula, because I already failed that once. And when I say once, I mean, of course, over and over again. :roll:

PointyHairedJedi 08-22-2004 09:55 PM

^ I forsee the potential for much fun here... :twisted:

NAHTMMM 08-22-2004 10:51 PM

Hmm. Actually, it should be fairly straightforward to generalize for a single ball... :?

catalina_marina 08-22-2004 11:39 PM

Uhm, well yes, if you stick to a certain number of balls, it is. But what if you vary that? And then, say, for 200 stories? Or for 150? Just to name a few.

It probably wouldn't even be all that hard, but I just suck at creating formulas. For now. :wink:

Draknek 08-23-2004 01:25 AM

(Draknek has been working this out for far too long)

Changing the number of floors is fairly trivial (once you get how to do it at all, that is - I didn't).

With only two balls, the formula is:

y = ceil(1/2*(sqrt(1+8x)-1))

Where y is the number of attempts you need to make and x is the number of floors. (Ceil means round up.)

Showing my working backwards, that formula is produced from this one:

1/2*y*(y+1) >= x

Which is, in turn, produced by this one:

(Sum of a between a=1 and a=y) >= x

Which is the original formula for 2 balls.

For one ball, the formula is:

y >=x

But that is equivelant to:

(Sum of 1 between a=1 and a=y) >= x

Going back to 2 balls:

(Sum of a between a=1 and a=y) >= x

Is the same as:

(Sum of (Sum of 1 between a=1 and a=b) between b=1 and b=y) >= x

Extending this, for three balls, it would be:

(Sum of (Sum of (Sum of 1 between a=1 and a=b) between b=1 and b=c) between c=1 and c=y) >= x

However, at 2:20 in the morning, I'm not willing to work that out and get a y=blah equation for three balls.

(Apologies if this makes little sense, is in a stupid order, or both. Draknek is tired now.)

Nic Corelli 08-23-2004 05:29 AM

<twitches painfully on the floor due to all the math>


No, my name is not Carlos Armando and you know that perfectly well, :P

catalina_marina 08-23-2004 10:54 AM

Ah yes, the sums. I thought of that, actually, but I couldn't make any direct formulas for them, after the first one. And my calculator is pretty slow on the recursive ones. :roll:

Alexia 08-23-2004 11:36 AM

Quote:

Originally Posted by Nic Corelli
<twitches painfully on the floor due to all the math>

<also twitches painfully on the floor>

PointyHairedJedi 08-23-2004 12:11 PM

*Head explodes*

Draknek 08-23-2004 01:35 PM

Ah, my work here is done.

(Almost)

I worked out this to be the formula for 3 balls:

y^3 + 3y^2 + 2y - 6x >= 0

But either I've forgotten how to factor polynominals with magnitude > 2, or I haven't learnt yet.

NAHTMMM 08-23-2004 02:23 PM

Hmm, I shall have to program an appropriate program at school, just for the fun of it :twisted:

Alexia 08-23-2004 02:53 PM

Fun? FUN?! Are you insane?

Oh, yes. You are. In that case, I withdraw the question :wink:

NAHTMMM 08-23-2004 06:05 PM

I'm still not particularly happy with the (Mathematica) function I came up with...

Code:

ballfall[maxfloors_] :=
        Do[For[i = 0; cmax = IntegerPart[maxfloors];
              cmin = 1, cmax - cmin > 0,
              i += 1, temp = Ceiling[(cmax + cmin)/2]; cmin = temp];
          Return[i], {1}]

^Highlight that code if you can't read it because of the colors ;)


Ideally that would be a rounding-down function, not a ceiling function, but IntegerPart leads to an infinite loop of evil DOOM! when cmin is one less than cmax :(... Still, the only mistakes should be that the smallest number of floors for which n trials are required might seem to require only n - 1 trials.


Here's a plot for up through 100 and a bit... ;)
http://img.photobucket.com/albums/v2.../ball1fall.gif

Draknek 08-23-2004 07:45 PM

That looks like the graph for 5 to an infinite number of balls.

Cat, are you sure that it's 9 tries minimum for 3 balls? I get 8.

EDIT: Nevermind. I wrote a program, which agrees with you.

Code:

#!/usr/bin/perl -w

use strict;

# Edit the next two values as appropriate

my $ballcount = 2;
my $floorcount = 100;

my $tries;
for ($tries = 0; 1; $tries++)
{
  if (howmanyfloors($tries,$ballcount) >= $floorcount)
  {
    print "It takes a maximum of $tries tries to check $floorcount floors with $ballcount balls.\n";
    exit;
  }
}

sub howmanyfloors
{
  my $tries = shift;
  my $ballcount = shift;
 
  # Can't check any floors without any balls
  return 0 if ($ballcount < 1);
   
  my $floors = 0;
  while ($tries > 0)
  {
    $tries -= 1;
    $floors += howmanyfloors($tries,$ballcount-1) + 1;
  }
 
  return $floors;
}


catalina_marina 08-23-2004 09:17 PM

I'm quite sure. You only get till the 92nd story with eight tries.

Draknek 08-23-2004 09:45 PM

Yeah, that's what my program told me, and I'm fairly certain now that it will be correct for any given values.

There's got to be a problem with my maths somewhere.

NAHTMMM 08-23-2004 09:54 PM

I don't even SEE much in the way of math in your program... :? ;)



Anyway, it would seem that the number of building heights such that you need a maximum of n one-ball trials to find the minimum height from which the ball will break is equal to 2^n (which isn't terribly surprising). That is, there are 2^(2-1) = 2 building heights that require 2 trials, 2^(3-1) = 4 building heights that require 3 trials, etc. And of course there's the exception of the building just one story tall, where you don't need to run any trials because you know the ball will break if you drop it from the first story since there aren't any other stories to drop from :lol:.


All times are GMT. The time now is 07:54 PM.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.