Live data from Hacker News

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

alexanderell.is

51–60 of 119 posts

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

#51

Earlier quoted context omitted.

Quoted post unavailable.

On August 22, 1994, David Donoghue threw an egg out of a helicopter onto a golf course in the UK, from a height of 213 meters (700 feet). He now has the record for the longest egg drop without breaking in the world (all without an outside structure for added protection!). https://www.scienceworld.ca/resource/egg-drop/ Eggs are evolutionarily designed to survive falling out of nests and perches. You assume that the eg…

I bet a human egg would survive undamaged even when dropped from 30,000 feet.

(Following Haldane's observation that "You can drop a mouse down a thousand-yard mine shaft and, on arriving at the bottom, it gets a slight shock and walks away. A rat is killed, a man is broken, a horse splashes.")

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

#52
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.)

I am still trying to wrap my head around the problem. Here's my attempt at your implementation in Raku:

    sub solutions-filter(@sols, &agg, Bool:D :$flip = False) {
        my @aggregates = @sols.map({ agg($_) });
    
        my %d;
        %d{$_} += %d{$_} ?? %d{$_} !! 1 for @aggregates;
    
        return @sols.grep({ %d{ agg($_) } == 1 }) if $flip;
        return @sols.grep({ %d{ agg($_) } != 1 });
    }
    
    my @candidates = ((1..99) X (1..99)).grep({ $_[0] ≤ $_[1] });
    my @ns = @candidates;
    
    for 1..7 {
        @ns = solutions-filter @ns, { $_[0] * $_[1] };
        @ns = solutions-filter @ns, { $_[0] + $_[1] };
    }
    
    say solutions-filter(@ns, { $_[0] * $_[1] }, :flip);

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

#53

Earlier quoted context omitted.

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.

>as soon as peter starts, all primes are off the table

How do you figure? If Peter is given 97 (a prime), how is he supposed to know that a) he's been given a product (puzzle doesn't say he was told it's a product) and b) if he knows he's been given a product how is he supposed to know 97 is prime? He wasn't told that in the puzzle either.

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

#55
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.

This reminded me of that joke about the physics experiment that assumes a perfectly spherical chicken in a vacuum :)

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

#56

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…

The ‘normal’ way to write something like that (I hope I got the range ends right) is

  for i in range(1, N):
    for j in range(1, j + 1):
      candidate_pairs.add((i, j))
Also, conceptually, you don’t have tuples, but multisets. If you were to use those, you wouldn’t need that if at all.

Multiset isn’t built-in to python, so you’d need to use an external package. Alternatively, write a class for storing pairs of ints i, j that enforces i ≤ j.

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

#57
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…

I was asked this one in a google phone interview in ~2009. I remember deriving that intervals of 10 floors were optimal in the two-egg 100-story case using some simple calculus and getting that far took me most of the hour. Your solution is super nice, but I hope you don't ask candidates to recreate it :P

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

#58

Earlier quoted context omitted.

On August 22, 1994, David Donoghue threw an egg out of a helicopter onto a golf course in the UK, from a height of 213 meters (700 feet). He now has the record for the longest egg drop without breaking in the world (all without an outside structure for added protection!). https://www.scienceworld.ca/resource/egg-drop/ Eggs are evolutionarily designed to survive falling out of nests and perches. You assume that the eg…

I bet a human egg would survive undamaged even when dropped from 30,000 feet. (Following Haldane's observation that "You can drop a mouse down a thousand-yard mine shaft and, on arriving at the bottom, it gets a slight shock and walks away. A rat is killed, a man is broken, a horse splashes.")

Thanks for quoting Haldane. I need to reread that excellent essay "on being the right size".

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

#59
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.

I hate how you are downvoted for an accurate statement. I love math, but I've come to understand from a teacher's perspective how accurate your statement can be. I liked your insight.

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

#60
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.

Thank you. We won’t be needing the rest of the hour. HR might be in touch.
Post reply on HN