
Ask HN: Can you work out how this is done? (repost) - ColinWright
Choose a polynomial <i>p(x)</i> with non-negative integer coefficients.<p>Now choose an integer <i>k</i> that&#x27;s larger than all the coefficients and evaluate <i>p(k).</i> You tell me <i>k</i> and <i>p(k),</i> and I tell you the polynomial.<p>So ...<p>Can you work out how to do it?<p>Do you find this interesting?<p>Please don&#x27;t give it away - by all means make it clear that you know how to do it (if you do!) but please don&#x27;t spoil it for the others.<p>But mostly I&#x27;m interested in knowing (eventually) how you think about it.<p>This is a repost because the first time I asked the question fell off the front page with very little reaction, and perhaps not many people saw it.  This is a one-shot repost - I&#x27;ll not post this question again.  I look forward to your answers (assuming there are any ...)<p>Thanks in advance.
======
matheist
> _Can you work out how to do it?_

Yes.

> _Do you find this interesting?_

Yes! I found it interesting because at first it seems like the solution space
ought to be many-to-one, not one-to-one, and it's not immediately clear why
the condition that _k_ is larger than the coefficients is the "right"
condition to fix that. I had to work through some examples to see the trick of
it.

hints (rot13):

1\. jungunccrafvslbhpubbfrxrdhnyfgjb

2\. jungunccrafvslbhpubbfrxrdhnyfgra

solution: jevgrcxvaonfrx

~~~
quickthrower2
vyvxrgbrknttrengr:jungunccrafvslbhpubbfrxrdhnyfbarzvyyvbanaqgurpbrssvpvragfneryrffgunagra

~~~
ColinWright
The simplest answer is for you to try it and see what happens. Nothing goes
wrong, and it just makes the solution/technique more obvious.

~~~
quickthrower2
Thanks! I was just saying how I arrived at the answer, how my mind works,
which I think is what the OP was looking to see - how people solve a problem
like this. Hope this comes up in my next whiteboard interview :-)

~~~
ColinWright
Oh, OK, that wasn't obvious to me, but now is - thanks for the clarification,
and for the answer. Interesting.

Your technique, by the way, is a classic puzzle solving technique that I've
used successfully many times, sometimes to great effect. Nice one.

------
artemisyna
If we know what k is, we've got an upper bound on the value of the roots.
Since we can express p(k) as (k-x_1)(k-x_2)...(k-x_n) (with x_i as roots), we
know that each (k-x_i) must be an integer factor of p(k).

Based on these facts, I'd probably just brute force it. Figure out the prime
factorization of p(k), then figure out all of the ways to express the x_i.

Note that this does also prove that the algorithm will not uniquely define an
expression for p(k). For example, if p(10) = 12, then (x-4)(x-8), (x-7)(x-6),
among others, satisfy.

This is mildly interesting to think about as someone who never was a math
major but maybe should have been. There are some interesting side bits (for
example, disproving uniqueness) but it does feel like there are more
"powerful" statements floating around this type of algebra.

~~~
ColinWright
I think you are missing that the coefficients must be non-negative. In fact
the answer is always unique, so you may want to rethink your approach.

~~~
artemisyna
Ah yeah, misread that there.

Express p(k) in base k. Those are your coefficients.

Pretty cute. :)

------
Someone
“Choose a polynomial p(x) with _non-negative_ integer coefficients”

I think you want to say _positive_ there, or mathematicians will exploit the
fact that common definitions (examples:
[https://en.wikipedia.org/wiki/Polynomial#Definition](https://en.wikipedia.org/wiki/Polynomial#Definition),
[http://mathworld.wolfram.com/Polynomial.html](http://mathworld.wolfram.com/Polynomial.html))
of _polynomial_ allow coefficients to be zero, making, for example, _x + 1_ (a
polynomial of degree 1) different from _0 x² + x + 1_ (a polynomial of degree
2)

Reason for that choice is that it makes the set of polynomials of degree n
closed under addition and subtraction)

~~~
ColinWright
Nope, I explicitly mean non-negative, because you are allowed polynomials like
x^4+x+2. In particular, polynomials are considered equivalent if they differ
only in terms that have zero coefficients. That means that 0x^2+x+1 is the
same polynomial as x+1. Further, _0x²+x+1_ is not a polynomial of degree 2,
because the degree is the highest power with a non-zero coefficient.

So the question is fine as it stands.

~~~
nanis
[redacted because I was completely wrong, missing the obvious ;-)] ... See
child comment.

~~~
ColinWright
> _No it is not. Your statement of the problem does not rule out only the
> coefficient of x^0 being positive, and the rest being zero._

You are correct that we permit any and/or all coefficients to be zero,
allowing the case that p(x)=665. That is intentional.

> _Just saying the coefficients are all nonnegative, the polynomial p(k) = 665
> also is a solution for the case k = 6 and p(6) = 665._

No it isn't, because you have evaluated at 6, which is not larger than all the
coefficients. Specifically, 6 is not larger than 665.

So I still claim that the question is fine as it stands. I do appreciate you
trying to poke holes in it, though. Thanks.

 _(Added in edit: Given that you 've retracted that, would you like me to
remove this comment?)_

------
cm2012
It's amazing how far away I am from being able to figure this out :)

~~~
ColinWright
Cool!

It's nice that you've found this, and are interested. There are clues
elsewhere in the thread, but email me for another clue, or an explanation.
Address is in my profile.

------
detaro
Hm, seems pretty straightforward. Can't think of any "interesting"
consequences right now, but I wouldn't be surprised if there's a few
interesting things about it that I'm not thinking of right now.

~~~
ColinWright
If you think it's straight-forward then here's an example:

k=7, p(k)=12028

What's p(x)? How did you find it?

~~~
detaro
[https://pastebin.com/A3AxRkDT](https://pastebin.com/A3AxRkDT)

~~~
ColinWright
Just out of interest, can you find a connection to something more "everyday"
??

~~~
detaro
[redacted]

~~~
ColinWright
Yup.

I guess that since the post (and the previous) seems to have attracted almost
no interest, the fact that you've given it away doesn't really matter -
probably very few people are reading it anyway.

In my experience most people find this connection surprising, and you can get
a sense of that from some of the other reactions here, although I deduce from
your tone that you don't. Which I find interesting.

Thank you for interacting - any further comments would be welcome.

~~~
detaro
Oh, sorry, I thought you asking meant you wanted me to post the details,
should have looked at the entire thread again :/ EDIT: could still edit, so
edited.

I guess I find it not that interesting because I spent a lot of high school
with math and math puzzles, so my threshold for "surprising" is higher -
although when I wrote the first comment I hadn't made the connection, only
when I typed it out later, in a slightly different form than I had in my head
it was clear.

~~~
ColinWright
Oh - thanks for redacting - appreciated. Mind you, very, very few people seem
to be interested, which I find curious.

Nice that you didn't initially make the connection, and it came to you later -
that's a nice progression. Thanks for letting me know.

------
nanis
The question is not well defined. If _m_ is the degree of the polynomial, you
want _∀ i ∈ {0, ..., m}, c_i ≥ 0_ and _∃ i ∈ {1, ..., m}, c_i > 0_. Otherwise
the solution is either trivial or not unique.

> Do you find this interesting?

Depends. For a pedagogical tool in 5th to 8th grades, maybe.

There may be some reason it is a compelling exercise which I am not seeing
though. So, you might want to explain why you find this interesting enough to
post it twice.

~~~
ColinWright
I find it odd that you think the question is not well defined. Choose a
polynomial with non-negative integer coefficients. Note that under the usual
conventions, the polynomials x^2+1 and x^2+0x+1 are the same. Does that cover
the situation you're worried about? Seriously, I don't know anyone who would
say that x^2+1 and x^2+0x+1 are different, so maybe I'm not seeing what you're
worried about.

However, given that, does it answer your objection?

As to why I think it's interesting, I think it's slightly surprising that
given k=6 and p(k)=665 then the polynomial is uniquely identified as
3x^3+2x+5.

Do you not find that surprising? If you _don 't_ find it surprising, how would
you explain it?

~~~
nanis
> _I find it odd that you think the question is not well defined._

You must assume that at least some of the coefficients of the _x_ terms are
non-zero.

> _Do you not find that surprising?_

No.

> _how would you explain it?_

I think it is up to you to explain why this is interesting.

Without the condition that _k_ is greater than all the coefficients, the
solution is clearly non-unique.

Given that, the assumption of the coefficients are integers, and that the
solution is not a constant polynomial, the statement becomes equivalent to "
_division is a function_ ".

~~~
ColinWright
>> _I find it odd that you think the question is not well defined._

> _You must assume that at least some of the coefficients of the x terms are
> non-zero._

That turns out not to be the case.

>> _Do you not find that surprising?_

> _No._

Interesting.

>> _how would you explain it?_

> _I think it is up to you to explain why this is interesting._

So far, many people who are clearly intelligent seem to miss that it works at
all, let alone how it works. You appear so far to be among them. As I've said
elsewhere, I appreciate that you are trying to poke holes in it, but it really
is complete and correct as stated.

> _Without the condition that k is greater than all the coefficients, the
> solution is clearly non-unique._

Well, yes. That's why having k greater than all the coefficients is a
requirement. That's why your example in another comment elsewhere is not an
example of the puzzle failing - it does not satisfy the condition that _k_
must exceed all the coefficients.

> _Given that, the assumption of the coefficients are integers, and that the
> solution is not a constant polynomial, the statement becomes equivalent to
> "division is a function"._

I don't see why this is true - perhaps you could expand on it? Why is the
problem statement equivalent to saying _" Division is a function."_?

So now I don't understand what you're trying to say or do. The question as
stated is fine - an example that doesn't satisfy the conditions isn't a
counter-example. So at least one of us is confused.

So let me state clearly, rather than having a bitty back'n'forth.

You pick a polynomial _p(x)_ with non-negative integer coefficients. You
choose an integer _k_ that's larger than all the coefficients of _p(x)_. You
tell me _k_ and _p(k)_. In return, I tell you _p(x)._

So:

Are you claiming this doesn't work?

Are you claiming it's trivial to accomplish?

Are you claiming it's obvious why it works?

I'm no longer sure what you're claiming, so I thought I'd ask clearly and
plainly.

~~~
nanis
> Are you claiming this doesn't work?

No, I am not. I misinterpreted the "larger than all coefficients" because I
was sure that the condition that at least one of the coefficients other than
the constant term had to be positive. You pointed out my mistake, you are
correct, thank you.

> Are you claiming it's trivial to accomplish?

It is easy to state what you need to do. Find largest _a_ such that _k^a ≤
p(k)_. Find _p(k) / k^a_ using integer division. Because division is a
function, there is unique quotient and unique remainder. The quotient is your
first coefficient. Take the remainder, repeat.

~~~
ColinWright
Right - that's one way of doing it. It's not the way I first thought of, and
the other way I have has a connection to something else that I think makes it
all kinda nice. That solution is elsewhere in the thread, but here it is in
rot13:

jevgrcxvaonfrxnaqgurqvtvgfnergurpbrssvpvragf

I'm pleased we've got it sorted, though. Thanks for your responses, and I'd be
happy to hear more thoughts.

------
impendia
Or, roughly equivalently, "our notation for writing down integers makes
sense".

------
techbio
I think of it like a coin counting machine.

~~~
ColinWright
I don't see how that helps - can you elaborate?

~~~
techbio
The face value of each coin is multiplied by the count of the coin type to
total to the purse.

Or rather, the sum of the nth powers of k multiplied by each positive
coefficient equals the value of the function at k.

Edit: Source in sibling.

~~~
ColinWright
Wow, what an interesting approach! Thank you ... I've copied that out to a
file and I'll study it more later.

Cheers!

~~~
techbio
Cheers to you. Let me know how close it was to what you were looking for.

[https://github.com/techbio/CoinCounting](https://github.com/techbio/CoinCounting)

~~~
ColinWright
What you've done is not at _all_ close to the solutions I already have, so
it's _exactly_ what I was looking for. On the one hand it's very much more
complex, but on the other hand it's a more generic and general solution.

The solutions I have are elsewhere in this thread, sometimes in disguise, and
I'm gestating a blog post which I'll eventually submit. If you want to know
more feel free to email me - address is in my profile.

 _Added in edit: I would add that your code gives no hint as to why the
solution should be unique._

~~~
techbio
It is not going to handle a vast range of inputs, including for example, p(k)
= 665, for the basic reason that my code is a direct response to your request
for an explanation and not proposed as a complete solution for the request of
your original submission.

Corrections requested, please. I would like to explore this paradigm to
accurately address the problem in an exact way.

~~~
ColinWright
I'll reply to your email ... thanks.

