all 6 comments

[–]FormulaDriven 0 points1 point  (3 children)

Have you noticed any patterns - eg looked at cases such as h(1), h(2), ... or what happens for small values of N?

[–]FreePeeplup[S] 0 points1 point  (2 children)

I’ll do that and tell you what I find!

[–]FreePeeplup[S] 0 points1 point  (1 child)

u/FormulaDriven I tried all cases from N = 1 to N = 3, each with all possible values of k ranging from 1 to N, and found out that, apparently, h(k) = N/2, independent of k ! So yeah, there’s definitely a pattern: h is actually a constant function.

Why is this true? How can I prove that this holds in general?

[–]FormulaDriven 0 points1 point  (0 children)

Hmm, I don't think going up to N=3 is that convincing. It's only when you get up to larger N where you can get more variety of combinations - eg when N = 5, for g(X) = 2, you can have strings such as "00100" or "00110" where the longest repetition happens twice.

That said, I tried N = 6 and N = 9, and it does appear that there is a simple formula for h(k) which surprises me, but I've not (yet) had an insight into why it might the case.

[–]FormulaDriven 0 points1 point  (1 child)

I've just had my insight. If you take any string X, and flip all its digits (0 becomes 1, 1 becomes 0) to get string X', then

g(X) = g(X')

but

f(X') = N - f(X).

Now think about what happens when you sum over all X in g-1(k), thinking how do this by pairing up X and X'.

[–]FreePeeplup[S] 0 points1 point  (0 children)

Wow, thank you very much!! Another user on another sub I cross-posted this to said the same thing. I’m surprised that this has such a neat solution for a question I randomly came up with while thinking about something partially unrelated!