I apologize for the lack of an even better title. The main reason I couldn't find a better one is because I have a problem that I cannot find reference anywhere. I am pretty sure it has a name, but I'm afraid I simply don't know it.

I'm given an algorithm that starts with four numbers $a$, $b$, $c$ and $d$ which can be chosen freely. After each iteration, the numbers are recalculated as shown in the following images. $a_{n+1}=|a_n-b_n|\ $, $b_{n+1}=|b_n-c_n|\ $, $c_{n+1}=|c_n-d_n|\ $, $d_{n+1}=|d_n-a_n|\ $ for all $n\gt0$.

algorithm to produce neigh

After a certain amount of time, this algorithm always results in all four columns ending and remaining at 0. Or so it appears. You can quickly try it out by replicating it in Excel or any other spreadsheet program.

The goal is to choose the four starting numbers a, b, c and d in such a way, that the columns all jump to 0 after the 50th iteration or later.

I have difficulties understanding how one can outsmart this algorithm, i.e., to make this algorithm compute as many rounds as possible before reaching all 0's. I've tried a brute force method by simple giving a, b, c and d random numbers with maximum lengths of 30 digits. And then seeing how far I can get. I let my computer try that for eight hours last night and the best I came up with was 17 several times - so obviously pure random brute force will not work and I will need a more thoughtful approach.

I'd be glad about any ideas!

  • 1
    $\begingroup$ Welcome to Computer Science! You have presented an interesting problem very clearly. If this problem comes from an online programming contest or course, could you please add a URL in the question? If it comes from a book or a paper, a reference. Besides paying proper attribute to the original source (we do not want to commit plagiarism), all that information also motivates and helps people answer your question faster and better. $\endgroup$ – John L. Oct 25 '18 at 9:17
  • $\begingroup$ What's your actual question, here? You say you're trying to "outsmart this algorithm" but I have no idea what that means. Perhaps if you define the problem clearly, a title will become obvious. Perhaps it's something about the convergence of four interdependent sequences of integers? $\endgroup$ – David Richerby Oct 26 '18 at 11:20
  • $\begingroup$ @Apass.Jack If the problem is very clear to you, could you edit the question to explain what it is? I don't actually see any problem statement in the question at all: it defines four sequences of numbers and says something about "outsmarting" some "algorithm" but what does that mean? What's the goal? $\endgroup$ – David Richerby Oct 26 '18 at 11:23
  • 1
    $\begingroup$ @DavidRicherby, I will ask the questioner to update it while chatting with him (he should have seen this message by now). If still not clear enough, I might give a hand since I know exactly what it is about. $\endgroup$ – John L. Oct 26 '18 at 11:37

I am a bit cautious just in case you might be taking part of some kind of open competition or exam.

Before I could reasonably believe that you are raising this question in good faith, I will just say I can reach 51 iterations without going to all zeros using less than 18 digits for each number.

As an evidence that I do have an answer, here are the last 5 digits of my numbers. This will not help anybody to get a better answer, except when you are super good at math, in which situation you probably do not need this too tenuous a hint anyway. However, it can be used to prove beyond any doubt in the future that I did know an answer. $$(***00000, ***22634, ***22881, ***60047)$$

Per request of the questioner, I will explain the simple "secret" of how to get an answer briefly. A full update may or may be followed later.

What you want is to let $a_1, b_1,c_1,d_1$ look like $a_0, b_0,c_0,d_0$ exactly. Since they look like exactly, the $a_2, b_2, c_2, d_2$ will look like $a_1, b_1, c_1, d_1$ exactly. You see you can actually go on forever. It will break down only when we cannot express the number accurately enough in its numerical representation, which is enforced since the geocacher owner does not accept values like $\sqrt 2$ (just for an example; there may or may not be a $\sqrt 2$ in my answer).

What does it mean by exactly alike? Well, for example, if the two circles of numbers are the same except by a factor and a rotation.

  • 1
    $\begingroup$ Thank you for answer! I am not entering in a competition. It's a puzzle to getting the coordinates of a Geocache, specifically this one: geocaching.com/geocache/GC7K67Q_4-zahlen-stufe-5 And it happens to be a compsci puzzle. The description is in German, but this is also where I got the image from. In case you don't know what Geocaching is, here is a short introduction: geocaching.com/blog/2018/03/what-is-geocaching I'd be grateful if you could explain to me how you solved the problem! $\endgroup$ – c42 Oct 25 '18 at 10:11
  • $\begingroup$ I am hesitant to give out how I solved the problem since, then, you will be able to get the coordinates of that Geocache (I just got that coordinates by submitting my numbers). I knew Geocaching, but I am not familiar the with its general rules and the specific rules of that Geocache. Are you allowed to get answers by asking on a public site? Is it respectful if I reveal the coordinates here? $\endgroup$ – John L. Oct 25 '18 at 18:29
  • 1
    $\begingroup$ In general, it is not forbidden at all to ask for help - neither internally, like asking other geocachers or the cache owner, nor by asking for help externally. However, directly posting the coordinates here would probably be a little too direct, I agree. My biggest interest is currently, from a computer scientist's point of view, understanding the algorithm, not finding the geocache. So, if you would help me out with how you found the solution instead of telling me your numbers, it would still stay a challenge since it still has to be understood and put into code. $\endgroup$ – c42 Oct 25 '18 at 20:22
  • $\begingroup$ Some of the people having logged the cache admit that they did not even solve the puzzle but instead were told where the cache is by others - which is, in my opinion, much further away from a true self-found solution than my current situation. I could do the same if I really wanted to, but since this has been bugging me for days, I am truly interested in understanding the algorithm. $\endgroup$ – c42 Oct 25 '18 at 20:54
  • 1
    $\begingroup$ I have accepted the answer as correct after Apass.Jack had to experience what an utter failure I am in math. After lots of nudges and hints up to him basically presenting his solution, I now have and have understood his solution thoroughly and am very thankful for his input. I hope future colleagues with less mathematical disabilitiy will understand the answer provided. $\endgroup$ – c42 Oct 29 '18 at 22:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.