How to find the length of an indefinitely repeated sequence in a list

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
4
down vote

favorite












Here, I am not looking for simply a repeated element, but an indefinitely repeated sequence. For example, if I have the list



1,3,4,3,4,2,3,3,2,3,3,2,3,3,2,3,3,2,3,3


I would like Mathematica to output $3$, since the sequence $(2,3,3)$ (with length 3) repeats until the end of the sequence after a certain point. Note, the repeated sequence needs to continue until the end of the list. For example, the sequence $(3,4)$ does repeat itself near the beginning of the list, however I would not want an output of $2$ due to this repetition since the sequence $(3,4)$ does not continue after a certain point.



More formally: If I input a list for which the $i^th$ element is $x_i$, I want Mathematica to output the smallest number $n$ for which $x_i=x_i+n$ for all sufficiently large $i$.



What function/code would allow me to input a list and then would output the desired result?










share|improve this question

















  • 1




    duplicate?: Find cycle length in a list
    – kglr
    8 hours ago














up vote
4
down vote

favorite












Here, I am not looking for simply a repeated element, but an indefinitely repeated sequence. For example, if I have the list



1,3,4,3,4,2,3,3,2,3,3,2,3,3,2,3,3,2,3,3


I would like Mathematica to output $3$, since the sequence $(2,3,3)$ (with length 3) repeats until the end of the sequence after a certain point. Note, the repeated sequence needs to continue until the end of the list. For example, the sequence $(3,4)$ does repeat itself near the beginning of the list, however I would not want an output of $2$ due to this repetition since the sequence $(3,4)$ does not continue after a certain point.



More formally: If I input a list for which the $i^th$ element is $x_i$, I want Mathematica to output the smallest number $n$ for which $x_i=x_i+n$ for all sufficiently large $i$.



What function/code would allow me to input a list and then would output the desired result?










share|improve this question

















  • 1




    duplicate?: Find cycle length in a list
    – kglr
    8 hours ago












up vote
4
down vote

favorite









up vote
4
down vote

favorite











Here, I am not looking for simply a repeated element, but an indefinitely repeated sequence. For example, if I have the list



1,3,4,3,4,2,3,3,2,3,3,2,3,3,2,3,3,2,3,3


I would like Mathematica to output $3$, since the sequence $(2,3,3)$ (with length 3) repeats until the end of the sequence after a certain point. Note, the repeated sequence needs to continue until the end of the list. For example, the sequence $(3,4)$ does repeat itself near the beginning of the list, however I would not want an output of $2$ due to this repetition since the sequence $(3,4)$ does not continue after a certain point.



More formally: If I input a list for which the $i^th$ element is $x_i$, I want Mathematica to output the smallest number $n$ for which $x_i=x_i+n$ for all sufficiently large $i$.



What function/code would allow me to input a list and then would output the desired result?










share|improve this question













Here, I am not looking for simply a repeated element, but an indefinitely repeated sequence. For example, if I have the list



1,3,4,3,4,2,3,3,2,3,3,2,3,3,2,3,3,2,3,3


I would like Mathematica to output $3$, since the sequence $(2,3,3)$ (with length 3) repeats until the end of the sequence after a certain point. Note, the repeated sequence needs to continue until the end of the list. For example, the sequence $(3,4)$ does repeat itself near the beginning of the list, however I would not want an output of $2$ due to this repetition since the sequence $(3,4)$ does not continue after a certain point.



More formally: If I input a list for which the $i^th$ element is $x_i$, I want Mathematica to output the smallest number $n$ for which $x_i=x_i+n$ for all sufficiently large $i$.



What function/code would allow me to input a list and then would output the desired result?







list-manipulation sequence






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 9 hours ago









volcanrb

1534




1534







  • 1




    duplicate?: Find cycle length in a list
    – kglr
    8 hours ago












  • 1




    duplicate?: Find cycle length in a list
    – kglr
    8 hours ago







1




1




duplicate?: Find cycle length in a list
– kglr
8 hours ago




duplicate?: Find cycle length in a list
– kglr
8 hours ago










1 Answer
1






active

oldest

votes

















up vote
4
down vote



accepted










Perhaps this?:



Length@Last@FindTransientRepeat[
1, 3, 4, 3, 4, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2]
(* 3 *)


For whether the second argument 2 is sufficient for all your inputs, see FindTransientRepeat.






share|improve this answer




















    Your Answer





    StackExchange.ifUsing("editor", function ()
    return StackExchange.using("mathjaxEditing", function ()
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
    );
    );
    , "mathjax-editing");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "387"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f185811%2fhow-to-find-the-length-of-an-indefinitely-repeated-sequence-in-a-list%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    4
    down vote



    accepted










    Perhaps this?:



    Length@Last@FindTransientRepeat[
    1, 3, 4, 3, 4, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2]
    (* 3 *)


    For whether the second argument 2 is sufficient for all your inputs, see FindTransientRepeat.






    share|improve this answer
























      up vote
      4
      down vote



      accepted










      Perhaps this?:



      Length@Last@FindTransientRepeat[
      1, 3, 4, 3, 4, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2]
      (* 3 *)


      For whether the second argument 2 is sufficient for all your inputs, see FindTransientRepeat.






      share|improve this answer






















        up vote
        4
        down vote



        accepted







        up vote
        4
        down vote



        accepted






        Perhaps this?:



        Length@Last@FindTransientRepeat[
        1, 3, 4, 3, 4, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2]
        (* 3 *)


        For whether the second argument 2 is sufficient for all your inputs, see FindTransientRepeat.






        share|improve this answer












        Perhaps this?:



        Length@Last@FindTransientRepeat[
        1, 3, 4, 3, 4, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2]
        (* 3 *)


        For whether the second argument 2 is sufficient for all your inputs, see FindTransientRepeat.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 9 hours ago









        Michael E2

        143k11192460




        143k11192460



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f185811%2fhow-to-find-the-length-of-an-indefinitely-repeated-sequence-in-a-list%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay