How to find the length of an indefinitely repeated sequence in a list
Clash 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?
list-manipulation sequence
add a comment |
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?
list-manipulation sequence
1
duplicate?: Find cycle length in a list
– kglr
8 hours ago
add a comment |
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?
list-manipulation sequence
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
list-manipulation sequence
asked 9 hours ago
volcanrb
1534
1534
1
duplicate?: Find cycle length in a list
– kglr
8 hours ago
add a comment |
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
add a comment |
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
.
add a comment |
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
.
add a comment |
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
.
add a comment |
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
.
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
.
answered 9 hours ago
Michael E2
143k11192460
143k11192460
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
duplicate?: Find cycle length in a list
– kglr
8 hours ago