Skip to main content

This is an extended comment, and should give you an answer to your first question.

If you are fine with your current code style, I did find a setting of your priority of Shortest and Longest that gives you the expected result. So here they are:

RealDigits[99/700, 10, 24][[1]]/. {Shortest[pre___, 3], 
 Longest[Repeated[Shortest[r__Longest[Repeated[Shortest[rep__, 1], {2, Infinity}]], 
 Shortest[inc___, 2]} /; 
 MatchQ[{rrep}, {inc, __}] :> {{pre}, {rrep}, {inc}})

In my experiments, I found that the priority of Shortest and Longest is not related, so the setting for Longest can be removed. If you are curious why I have this conclusion, here is the list of "full" parameters I found:

{{3, 1, 4, 2}, {4, 1, 2, 3}, {4, 1, 3, 2}, {4, 2, 1, 3}}

The third argument is for Longest, and clearly its priority does not matter.

Also, I think {2, Infinity} in your Repeat can't be omitted, otherwise the program tends to regard the whole sequence as the recurring period.

I didn't explore further into this problem or fully tested the settings, so I am not sure how well it can generalize.

This is an extended comment, and should give you an answer to your first question.

If you are fine with your current code style, I did find a setting of your priority of Shortest and Longest that gives you the expected result. So here they are:

RealDigits[99/700, 10, 24][[1]]/. {Shortest[pre___, 3], 
 Longest[Repeated[Shortest[r__, 1], {2, Infinity}]], 
 Shortest[inc___, 2]} /; 
 MatchQ[{r}, {inc, __}] :> {{pre}, {r}, {inc}})

In my experiments, I found that the priority of Shortest and Longest is not related, so the setting for Longest can be removed. If you are curious why I have this conclusion, here is the list of "full" parameters I found:

{{3, 1, 4, 2}, {4, 1, 2, 3}, {4, 1, 3, 2}, {4, 2, 1, 3}}

The third argument is for Longest, and clearly its priority does not matter.

Also, I think {2, Infinity} in your Repeat can't be omitted, otherwise the program tends to regard the whole sequence as the recurring period.

I didn't explore further into this problem or fully tested the settings, so I am not sure how well it can generalize.

This is an extended comment, and should give an answer to your first question.

If you are fine with your current code style, I did find a setting of your priority of Shortest and Longest that gives you the expected result. So here they are:

RealDigits[99/700, 10, 24][[1]]/.{Shortest[pre___, 3], 
 Longest[Repeated[Shortest[rep__, 1], {2, Infinity}]], 
 Shortest[inc___, 2]} /; MatchQ[{rep}, {inc, __}] :> {{pre}, {rep}, {inc}}

In my experiments, I found that the priority of Shortest and Longest is not related, so the setting for Longest can be removed. If you are curious why I have this conclusion, here is the list of "full" parameters I found:

{{3, 1, 4, 2}, {4, 1, 2, 3}, {4, 1, 3, 2}, {4, 2, 1, 3}}

The third argument is for Longest, and clearly its priority does not matter.

Also, I think {2, Infinity} in your Repeat can't be omitted, otherwise the program tends to regard the whole sequence as the recurring period.

I didn't explore further into this problem or fully tested the settings, so I am not sure how well it can generalize.

added 240 characters in body
Source Link
vapor
  • 7.9k
  • 2
  • 23
  • 56

This is an extended comment, and should give you an answer to your first question.

If you are fine with your current code style, I did find a setting of your priority of Shortest and Longest that gives you the expected result. So here they are:

RealDigits[99/700, 10, 24][[1]]/. {Shortest[pre___, 3], 
 Longest[Repeated[Shortest[r__, 1], {2, Infinity}]], 
 Shortest[inc___, 2]} /; 
 MatchQ[{r}, {inc, __}] :> {{pre}, {r}, {inc}})

In my experiments, I found that the priority of Shortest and Longest is not related, so the setting for Longest can be removed. If you are curious why I have this conclusion, here is the list of "full" parameters I found:

{{3, 1, 4, 2}, {4, 1, 2, 3}, {4, 1, 3, 2}, {4, 2, 1, 3}}

The third argument is for Longest, and clearly its priority does not matter.

Also, I think {2, Infinity} in your Repeat can't be omitted, otherwise the program tends to regard the whole sequence as the recurring period.

I didn't explore further into this problem or fully tested the settings, so I am not sure how well it can generalize.

This is an extended comment, and should give you an answer to your first question.

If you are fine with your current code style, I did find a setting of your priority of Shortest and Longest that gives you the expected result. So here they are:

RealDigits[99/700, 10, 24][[1]]/. {Shortest[pre___, 3], 
 Longest[Repeated[Shortest[r__, 1], {2, Infinity}]], 
 Shortest[inc___, 2]} /; 
 MatchQ[{r}, {inc, __}] :> {{pre}, {r}, {inc}})

In my experiments, I found that the priority of Shortest and Longest is not related, so the setting for Longest can be removed.

Also, I think {2, Infinity} in your Repeat can't be omitted, otherwise the program tends to regard the whole sequence as the recurring period.

I didn't explore further into this problem or fully tested the settings, so I am not sure how well it can generalize.

This is an extended comment, and should give you an answer to your first question.

If you are fine with your current code style, I did find a setting of your priority of Shortest and Longest that gives you the expected result. So here they are:

RealDigits[99/700, 10, 24][[1]]/. {Shortest[pre___, 3], 
 Longest[Repeated[Shortest[r__, 1], {2, Infinity}]], 
 Shortest[inc___, 2]} /; 
 MatchQ[{r}, {inc, __}] :> {{pre}, {r}, {inc}})

In my experiments, I found that the priority of Shortest and Longest is not related, so the setting for Longest can be removed. If you are curious why I have this conclusion, here is the list of "full" parameters I found:

{{3, 1, 4, 2}, {4, 1, 2, 3}, {4, 1, 3, 2}, {4, 2, 1, 3}}

The third argument is for Longest, and clearly its priority does not matter.

Also, I think {2, Infinity} in your Repeat can't be omitted, otherwise the program tends to regard the whole sequence as the recurring period.

I didn't explore further into this problem or fully tested the settings, so I am not sure how well it can generalize.

deleted 10 characters in body
Source Link
vapor
  • 7.9k
  • 2
  • 23
  • 56

This is an extended comment, and should give you an answer to your first question.

If you are fine with your current code style, I did find some settingsa setting of your priority of Shortest and Longest that gives you the expected result. So here they are:

{{3RealDigits[99/700, 110, 424][[1]]/. {Shortest[pre___, 2}3], {4
 Longest[Repeated[Shortest[r__, 11], {2, 3Infinity}]], {4, 
 1Shortest[inc___, 3,2]} 2/; 
 MatchQ[{r}, {4inc, 2__}] :> {{pre}, 1{r}, 3{inc}})

The ordering isIn my experiments, I found that the same as your codepriority of (say your current code's settingShortest and Longest is not related, so the setting for {2, 3, 4, 1}Longest) can be removed. 

Also, in those valid settings, I think {2, Infinity} in your Repeat can't be omitted, otherwise the program tends to regard the whole sequence as the recurring period.

I didn't explore further into this problem or fully tested thosethe settings, so I am not sure how well theseit can generalize. And I don't know exactly the reason those settings worked.

This is an extended comment, and should give you an answer to your first question.

If you are fine with your current code style, I did find some settings of your priority of Shortest and Longest that gives you the expected result. So here they are:

{{3, 1, 4, 2}, {4, 1, 2, 3}, {4, 1, 3, 2}, {4, 2, 1, 3}}

The ordering is the same as your code (say your current code's setting is {2, 3, 4, 1}). Also, in those valid settings, {2, Infinity} in your Repeat can't be omitted, otherwise the program tends to regard the whole sequence as the recurring period.

I didn't explore further into this problem or fully tested those settings, so I am not sure how well these can generalize. And I don't know exactly the reason those settings worked.

This is an extended comment, and should give you an answer to your first question.

If you are fine with your current code style, I did find a setting of your priority of Shortest and Longest that gives you the expected result. So here they are:

RealDigits[99/700, 10, 24][[1]]/. {Shortest[pre___, 3], 
 Longest[Repeated[Shortest[r__, 1], {2, Infinity}]],  
 Shortest[inc___, 2]} /; 
 MatchQ[{r}, {inc, __}] :> {{pre}, {r}, {inc}})

In my experiments, I found that the priority of Shortest and Longest is not related, so the setting for Longest can be removed. 

Also, I think {2, Infinity} in your Repeat can't be omitted, otherwise the program tends to regard the whole sequence as the recurring period.

I didn't explore further into this problem or fully tested the settings, so I am not sure how well it can generalize.

Source Link
vapor
  • 7.9k
  • 2
  • 23
  • 56
Loading