Logic and Math Puzzles

Post all the logic and math puzzles you know, or post your solutions to the following ones.

>You want to buy a dog so you call the owner of the pet store. You ask the owner if they have any dogs and he says yes we have two. You then ask him if one is a male, he says yes. Assuming all dogs are either male or female, what is the probability the other dog is male.

>A bacteria culture in a petri dish doubles every hour. If the dish is full 8 hours after the experiment starts, when was it half full?

>How many bit strings of length 10 contain either 5 consecutive 1s or 5 consecutive 0s

>Suppose 21 boys and 21 girls enter a math contest. Furthermore, suppose that each entrant answers at most 6 questions, and for every boy-girl pair, there is at least one question they both solved. Show that there is a question that is solved by at least 3 girls and 3 boys

>How many ways are there for a four horse race to finish if draws are allowed?

>The amount of particles in the universe was estimated to be 33*2^257, how many digits are in this number?

>Find a constant time algorithm which sums the digits of an inputed positive integer.

>Given an nxn chessboard where n is a positive integer, write a constant time algorithm which determines the number of squares on this chessboard.

>Given a mxn rectangular grid where m and n are positive integers, how many rectangles does it contain?

>What is the probability that a five card poker hand contains cards of five different kinds and does not contain a flush or straight?

Other urls found in this thread:

wolframalpha.com/input/?i=solve( 1 - sqrt(x² + y²) = sqrt( (x + 1/2)² + y²) - 1/2 = sqrt((x-a)² + (y-b)²) - (1-sqrt(a² + b²)), x, y)
ocf.berkeley.edu/~wwu/riddles/intro.shtml
twitter.com/NSFWRedditVideo

if you are looking for more puzzles, some user suggested these

>1/3
>7 hours
>222
>Answer too long to fit here
>75
>79
>Impossible
>Return: ((1/3) n^3 + (1/2) n^2 + (1/6) n)
>[math] {m \choose 2} {n \choose 2} [/math]
>~50%

Assume + - * / and % are all constant time

I'm trying to tackle a problem posted in the previous puzzles thread :

find the area of the sequence of circles tangent to the two semi-circles, and tangent to each previous circle (the first one, drawn in blue, is tangent to the 0x line), going toward A.

I could find the parameters of the first circle (by solving the equation saying that A1 is at the same distance of the two semi-circles and the 0x line.

I tried to derive a general formula to get the coordinates of the center of the next circle, but wolframalpha just gave me an overly complicated answer.

Maybe I could find the equation of the line containing the center of the circles.

wolframalpha.com/input/?i=solve( 1 - sqrt(x² + y²) = sqrt( (x + 1/2)² + y²) - 1/2 = sqrt((x-a)² + (y-b)²) - (1-sqrt(a² + b²)), x, y)

a and b are the coordinates of the center of a circle, and x and y the coordinates of the next one.

Finding the coordinates of A2 just seems impossible...

33*2^257 has 79 digits

How'd you get this answer?

[math]\texttt{33 * 2^257 // IntegerDigits // Length}[/math]

So you used a built in function defined for the purpose of counting an integer?

ocf.berkeley.edu/~wwu/riddles/intro.shtml

Have at it, m8s

excellent post

Number of digits of a number N is equal to
[eqn] \left\lceil {\frac{\log(N+1)}{\log(10)}} \right\rceil [/eqn]

nicely done

That's pretty common knowledge.

P(both male|one is male) = P(both male)/P(one is male) = 1/3

7

9

...

4! + 4C2*3! + 4C2*2!+ 4C3*2! + 1 = 85

floor(257/log2(10) + log10(33)) + 1 = 79

...

N^2 + (N-1)(N-1) + (N-2)(N-2) + ... 1 = n(n+1)(2n+1)/6

m(m+1)n(n+1)/4

...

So the earth is flat?

Why do people on /g/ and Veeky Forums do this?

>LOL U USED A BUILT IN TO IMPLEMENT A TRIVIAL THING?

they think reinventing the wheel makes them hardcore
[spoiler]obviously they didn't read SICP[/spoiler]

>WOOOOW You made Prolog in LISP. Anyone can do that. Now try to implement it from scratch

There's a type of joy and wonder that comes from discovering this type of answer for oneself.

>divided by log base 10 of 10

He made no indication that he did.

[eqn] \log(x) = \int_0^x \frac{dt}{t} [/eqn]

Typo. The lower bound of the integral should be 1.

>>Given an nxn chessboard where n is a positive integer, write a constant time algorithm which determines the number of squares on this chessboard.
wouldn't this just be n^2? sorry for brainlet

it's [math] \Sigma_{k = 1}^n \left( \begin{array}{c}n \\ k \end{array} \right) [/math]
Squares can be 1x1, 2x2, etc.

ohhh i see now, thanks. I thought it meant only the little black and white squares.

>Find a constant time algorithm which sums the digits of an inputed positive integer.

Inputed into what? If we use a (limited size) variable, we could calculate the value for all possible digits even when they are zero, and get an equal running time for all possible inputs. This could arguably be done even if we read the input as a string. Memory is not unlimited.

The cheat would be to define the algorithm to calculate all digits up to infinity. The definition of the algorithm would be constant time, even if it could never finish.

There are n^2 squares of the size 1x1.
There are (n-1)^2 squares of the size 2x2.
...
There is 1 square of the size nxn.

Total number is thus
[eqn]\sum_{k=1}^n k^2 [/eqn]

>>How many bit strings of length 10 contain either 5 consecutive 1s or 5 consecutive 0s

Fun problem.

First consider a string of 5 consecutive 1s. There are 5 possible configurations for the 5 consecutive 1s, but all of them leave 5 open spots.

For each configurative of consecutive 1s, we can add the possibilities for the remaining parts as such:

5 choose 0 + 5 choose 1 + 5 choose 2 + 5 choose 3 + 5 choose 4 + 5 choose 5.

Because in 5 choose 0 we are choosing 0 1s, which generates the string 00000
In 5 choose 1 we are choosing 1 1s so we generate strings like 10000, 01000, etc.

And so on. And my trustworthy calculator tells me that sum equals 32.

But for each configuration of 11111s, we have 5 arrangements of empty spots, so we multiply 32*5 = 160

For the case of 5 consecutive 0s it is the same. We get 160 configurations.

Then to find the total we add them but we need to substract one of each configuration which occurs in both lists. So we need to remove every list that contains 5 consecutive 1s and 5 consecutive 0s.

Luckily we can generate those lists easily: 0000011111 and 1111100000 and they are only two se we compute
160 + 160 - 2= 328

You're counting the strings with 6 or more consecutives 1s several times.

Here's a nice one: if you write down all the numbers from 1 to 1 million, how many times will you write down the number 2?

>>How many bit strings of length 10 contain either 5 consecutive 1s or 5 consecutive 0s
I'll try to take on it.

Let's count only zeroes:

First case, the string is in the beginning:
00000***** => 32 possibilities
Second case. The sequence starts at second element, but we have to exclude the first, therefore:
100000**** => 16 possibilities

Third:
*100000*** => 16
Fourth:
**1000000** = > 16
Fifth:
***100000* => 16
Sixth:
*****100000 => 16
To sum: 32 + 16 * 5 = 112

Same with ones: 112. However, some cases still overlap, them being 0000011111 and 1111100000.

So, the answer is 112 * 2 - 2 = 222

From 1 to 10:
1
From 10 to 100:
Each time 2 is in the first digit (10 times: 12, 22, 32...) and each time 2 is in the second digit (10 times: 20,21,22...) = 20
From 100 to 1000:
First digit: 100
Second digit: 100
Third digit: 100
= 300
Et cetera.
So, the answer:
654321 times.

>>You want to buy a dog so you call the owner of the pet store. You ask the owner if they have any dogs and he says yes we have two. You then ask him if one is a male, he says yes. Assuming all dogs are either male or female, what is the probability the other dog is male.

Single events dont have probability. Genderdistribution is not specified.

>>A bacteria culture in a petri dish doubles every hour. If the dish is full 8 hours after the experiment starts, when was it half full?

Could have been full one hour after start, unless it was first full after exactly eight hours.

>Single events dont have probability.
Look! It's a frequrntist! Let's laugh at him!

/3
no its not

axiomatic-math-fag

Nope

Oh whoops that's 10 million

Still nope though

>instead of log base 10 of X+1 over log base 10 of 10, which equals log base 10 of X+1, we consider log base e of X+1 over log base e of 10, which equals log base 10 of X+1 by a well-known result
Fuck off

Oh yeah, I fucked up. From 10 to 100 in the first digit 2 appears only 9 times, that is, 19 times.
To fix:
1..10: 1
1..100: 20
1..1000:300
...
1..1000000: 600000

Because it defeats the purpose of the challenge. All you did was look up the answer. These questions aren't asked because they're open problems without solution, they're asked to see if you can puzzle it out on your own.

You wouldn't get the job. There's a much more direct elegant way of getting this which also shows that it doesn't depend on the digit (could be 3 instead of 2), and also immediately shows how to generalise. You should immediately see that the answer in the case 1 to 1 million is 6*10^5 for any digit other than 1. More generally in the case of 1 to 10^k it's k*10^(k-1).

>1/3
what?
genders = 2
probably of 1 over the other is 1/2
first dog is established as male, meaning that the probably of both being male is 1/2 x 1/2 = 1/4

Every problem is either a solved problem, in which case you can google the solution, or an unsolved problem.

found the stack exchange coder

That is exactly what I've shown, I just didn't explicitly write the formula.

>genders = 2
user, I'm from the bureau of social justice and I'd like to ask you some questions about a post you made on an online forum. I was hoping you could invite me into your home and we could have a discussion.

You are the reason why some textbooks have foregone including solutions to problems.

PREACH