Live data from Hacker News

A Quick Puzzle to Test Your Problem Solving

nytimes.com

241–250 of 311 posts

Re: A Quick Puzzle to Test Your Problem Solving

#241
post #3

I'm curious to see more about the distribution of questions and answers people had, and how the HN population may differ from the NYT's. There will certainly be self selection bias here, but if you're willing to share how you did with others, please enter it here: https://docs.google.com/forms/d/17e5BIL0lH8OHsGj89Zdtdl8GeCV... The result summary is visible here: https://docs.google.com/forms/d/17e5BIL0lH8OHsGj89Zdtdl…

If you look at the raw answers, a lot of people who guessed the wrong answer according to: "What answer did you give?" said they got it right:

Right? What answer did you give?

Yes, double the previous number

Yes, Each number much larger than the previous

Yes, sequence must always increase by 1

Yes, Powers of 2

Yes, h = 2n, i = 2(n+1), j = 2(n+2) . n is an integer

Yes, Powers of 2

Re: A Quick Puzzle to Test Your Problem Solving

#242

Earlier quoted context omitted.

Remotely related: I've been interested for awhile in how the same initial terms of a sequence could possibly be generated by multiple rules. For example, you might have 2,3... And the rest of the sequence might look like either 2,3,4,5,6... or 2,3,5,8,13... or 2,3,5,7,11... or even 2,3,5,10,20... Clearly, on some level those sequences are all much less complicated than one defined as "The first term is 2, the second…

Fun fact: Mathemetica has a method FindSequenceFunction which does exactly what you describe. In my experience, however, it generally requires at least 4 terms. I'm not totally sure how the math behind it works (maybe it's similar to Eureqa?) but the results speak for themselves and are rather incredible. For example, if I run FindSequenceFunction on this input: {0, 1, 3, 8, 19, 43, 94, 201, 423, 880} Which is the nu…

Which is the number of 0,1 sequences of length n that contain two adjacent 1s

It sounds a lot simpler than that. There are n-1 places to put the adjacent 1s. For each of those, there are 2^(n-2) ways to complete the sequence with 0s and 1s. So the answer should be (n-1)*2^(n-2).

Edit: it isn't quite that simple, I'm counting sequences with multiple pairs of 1s multiple times.

By the way, Mathematica's formula looks a lot like the closed form for the Fibonacci sequence.

Re: A Quick Puzzle to Test Your Problem Solving

#243

Earlier quoted context omitted.

People familiar with unit testing and test driven development will feel at home with this kind of puzzle. That doesn't mean that they will be less biased in social/political decisions, it just means that this test will fail to prove a point.

I was just writing this out! I believe practice in unit testing is what let me get this question right. I almost submitted n^1, n^2, n^3 before I realized I didn't get any wrong answers and something didn't feel right. I credit this 'instinct' to having written thousands of tests, and trying to make them fail to make sure my tests weren't lying to me.

It's funny. Even though I got the right answer, looking back, I still see many holes in my tests. I only tested positive and negative integers. I didn't even think to try fractions, decimals, hex values, text, etc. and I was already expecting a confirmation bias test.

Re: A Quick Puzzle to Test Your Problem Solving

#246
post #7

It responds "No" to (10000000000000000, 10000000000000001, 10000000000000002) so the rule is not so simple after all :)

A test engineer walks into a bar. He orders a beer. He orders two beers. He orders 999999999 beers. He orders 1.00001 beers. He orders -42 beers. He orders 1048576 beers...

Yes, but did he think to order NaN beers?

Re: A Quick Puzzle to Test Your Problem Solving

#247

Earlier quoted context omitted.

Did you try floating point numbers? I didn't see anything in the text that said integers only.

I tried floating point numbers. Also, at 28 decimal places, the test breaks; it's not arbitrary precision. So, technically, the answer isn't simply "any ascending sequence of numbers".

The slightly-shorter 0.60000000000000000, 0.60000000000000001, 0.60000000000000002 will break it too, for what it's worth. If you punch those in to a Javascript console, you can see that the FP representation of all three is 0.6.

Re: A Quick Puzzle to Test Your Problem Solving

#248

Earlier quoted context omitted.

Fun fact: Mathemetica has a method FindSequenceFunction which does exactly what you describe. In my experience, however, it generally requires at least 4 terms. I'm not totally sure how the math behind it works (maybe it's similar to Eureqa?) but the results speak for themselves and are rather incredible. For example, if I run FindSequenceFunction on this input: {0, 1, 3, 8, 19, 43, 94, 201, 423, 880} Which is the nu…

Which is the number of 0,1 sequences of length n that contain two adjacent 1s It sounds a lot simpler than that. There are n-1 places to put the adjacent 1s. For each of those, there are 2^(n-2) ways to complete the sequence with 0s and 1s. So the answer should be (n-1)*2^(n-2). Edit: it isn't quite that simple, I'm counting sequences with multiple pairs of 1s multiple times. By the way, Mathematica's formula looks a…

OK, got it.

Let a_n be the number of sequences of 0s and 1s of length n, that do not contain a pair of 1s, and end in 0. Let b_n be similar, except that the sequences end in 1. These satisfy the recurrences a_{n+1} = a_n + b_n, and b_{n+1} = a_n. It follows that a_n satisfies the Fibonacci recurrence a_{n+1} = a_n + a_{n-1}. Starting from a_1 = 1, and a_2 = 2, we have a_n = F_{n+1}.

The total number of sequences of length n is 2^n, so the number we want is 2^n - a_n - b_n = 2^n - F_{n+1} - F_n = 2^n - F_{n+2}.

And this time it works :-). There might be a point about confirmation bias here, in that the trick is to count sequences that _don't_ contain a pair of 1s.

One drawback of Mathematica is that it has a very poor idea of the formulae that human readers will regard as simple.

Re: A Quick Puzzle to Test Your Problem Solving

#249
I think the first-known matching pattern plays a huge role. The original 2,4,8 sequence, for example, locked me in immediately to doubles of the previous number (causing me to test 1,2,4 and 7,14,28 and such). Had it been a different starting sequence (like 3,9,27), I might've based my guesses differently. Same for 1,2,3.

In other words, first impressions really are important.

Re: A Quick Puzzle to Test Your Problem Solving

#250
post #203

Earlier quoted context omitted.

got tricked even if I tested 1, 1, 1

1, 1, 1 was actually the test case that clued me in that n^1, n^2, n^3 couldn't be the right solution.

n=1?

But I totally see why it would cause you to pause and rethink your original idea :).

Post reply on HN