Live data from Hacker News

“I don't know the numbers”: a math puzzle

alexanderell.is

31–40 of 119 posts

Re: “I don't know the numbers”: a math puzzle

#31
post #3

Bonus meta-puzzle: the puzzle as stated is actually unsolvable. Both Sandy and Peter have to know something that the puzzle implies but does not actually stipulate that they know. What is it?

Is it that the other person was told either the sum or the product? Or that the number they were told is the sum or product? edit: After rereading the problem they weren’t told the parameters of the problem or even that they are participating in a puzzle.

process of elimination. as soon as peter starts, all primes are off the table. Given that, some number pairs which sum to the same number as just one other number pair where the second number pair has at least one prime are off the table. And so on and so forth. My instinct was to program the solution. Bet there are people who could do it in their heads.

Re: “I don't know the numbers”: a math puzzle

#32
post #28

Their code was horrific. My algorithm: import itertools import collections candidates = [s for s in itertools.product(range(100), range(100)) if s[0] (Usually, next step is variable names, comments, etc.)

My logic was similar, in R:

  library(dplyr)
  
  combos 
    filter(x  # Remove dupes
    mutate(sum = x + y, prod = x * y)
  
  find_singletons % group_by(!!sym(col)) %>% tally() %>% filter(n == 1)
    which(combos[[col]] %in% singletons[[col]])
  }
  
  for (i in 1:7) {
    # Peter: I don't know the numbers.
    combos 

Re: “I don't know the numbers”: a math puzzle

#34
post #3

Bonus meta-puzzle: the puzzle as stated is actually unsolvable. Both Sandy and Peter have to know something that the puzzle implies but does not actually stipulate that they know. What is it?

The fact that it's unsolvable as stated is precisely why I hate this puzzle.

Re: “I don't know the numbers”: a math puzzle

#35
post #32
post #28

Their code was horrific. My algorithm: import itertools import collections candidates = [s for s in itertools.product(range(100), range(100)) if s[0] (Usually, next step is variable names, comments, etc.)

My logic was similar, in R: library(dplyr) combos filter(x # Remove dupes mutate(sum = x + y, prod = x * y) find_singletons % group_by(!!sym(col)) %>% tally() %>% filter(n == 1) which(combos[[col]] %in% singletons[[col]]) } for (i in 1:7) { # Peter: I don't know the numbers. combos

To people who either know:

- both R and Python; or

- neither R nor Python:

Which of the solutions do you find more readable?

(I have my own opinion, but I'm biased)

Re: “I don't know the numbers”: a math puzzle

#36

This isn't quite right. This does find the solution when the problem is well-formed, but it doesn't prove that the solution is valid: if round == 15: for product in products: if len(products[product]) == 1: print('Peter: I do know the numbers') print(products[product][0]) return This should not return - it should continue iterating. If the problem (and the code) is correct, then it should only find one answer - but u…

Regarding the second snippet, yeah, that (i,j) test will always be true. And if the inner loop is changed from `range(1, N)` to `range(i, N`) then it will be totally unnecessary anyways to have the conditional. With that change every pair would be generated exactly once.

Re: “I don't know the numbers”: a math puzzle

#37

This isn't quite right. This does find the solution when the problem is well-formed, but it doesn't prove that the solution is valid: if round == 15: for product in products: if len(products[product]) == 1: print('Peter: I do know the numbers') print(products[product][0]) return This should not return - it should continue iterating. If the problem (and the code) is correct, then it should only find one answer - but u…

That's a good point! The `15` check relies on 1) knowing it will stop after 15 rounds as written in the problem (though I explore that later) and 2) assuming that there must be a single answer after 15 rounds (which I also explore later).

And that's true, the `(i, j)` check is spurious - I blame it on it being throwaway blog post code :)

Re: “I don't know the numbers”: a math puzzle

#38
post #28

Their code was horrific. My algorithm: import itertools import collections candidates = [s for s in itertools.product(range(100), range(100)) if s[0] (Usually, next step is variable names, comments, etc.)

Horrific is a new one! Thanks for posting your solution :)

Re: “I don't know the numbers”: a math puzzle

#39
post #8

That was a fun puzzle. I have another one that is math puzzle: > You are given two eggs, and access to a 100-storey tower. Both eggs are identical. The aim is to find out the highest floor from which an egg will not break when dropped out of a window from that floor. If an egg is dropped and does not break, it is undamaged and can be dropped again. However, once an egg is broken, that’s it for that egg. > If an egg b…

Quoted post unavailable.

Eggs can absolutely survive very far falls. You are making a lot of assumptions here. Like:

- This is a typical bird's egg. Most insect eggs for instance can survive any fall.

- This is a hard floor, not water, snow,...

- There is nothing to protect the egg.

- Floors are typical ~3m floors, not floors from a doll house.

- The experiment is done on earth

The point of maths is that it doesn't need to be grounded into the world. It is a "if A then B" machine. If A applies to a world then B will apply to that world too, and it will always be the case, it doesn't depend on experimental results.

It is great because scientists, engineers, etc... only have to show (with their experiments and measurements) that A applies to our world, and maths automatically tell them that B applies too, no need for extra experiments and measurements, except for verification.

So in this problem, if you use your "real world" experience with eggs, you only solve the problem for a limited set of preconditions. If you solve it properly, using maths, then it will work in any situation that matches the data of the problem, even for people of Pluto.

Also, if you want to talk "real life", I am not sure a 100 story building exists (there is 101, but exactly 100?). And if that building exists, does it have windows you can drop an egg from at every floor?

Re: “I don't know the numbers”: a math puzzle

#40
In case anyone else is confused like I was, the article is wrong about Sandy's first round. The article claims she can eliminate (1, 4) on the basis that it's the only pair that adds up to 5, but the author forgot about (2, 3), which was not eliminated by Peter's first round because it has the same product as (1, 6).

The algorithm itself is correct, and the answer it arrives at is correct.

Post reply on HN