Locate Start and End Positions of Repeated Sequences in a list
In versions 10 and later, you can get the result using a single function SequencePosition
:
repSeqPos = SequencePosition[#, {Repeated[a_, {2, Infinity}]}, Overlaps->False]&;
repSeqPos @ listA
{{1, 10}, {11, 13}, {14, 16}, {18, 48}, {51, 88}, {89, 99}, {100, 249}, {251, 253}, {255, 258}, {259, 260}, {268, 272}, {282, 283}, {285, 286}, {291, 292}, {311, 312}, {315, 316}, {318, 320}, {322, 324}, {327, 328}, {331, 332}, {333, 334}, {337, 338}, {339, 340}, {342, 343}, {352, 355}, {356, 359}}
fn[{{_, fp_}, ___, {_, lp_}}] := Flatten@{fp, lp}
fn[_] := Nothing
fn /@ SplitBy[MapIndexed[List, ListA], First]
{{1, 10}, {11, 13}, {14, 16}, {18, 48}, {51, 88}, {89, 99}, {100, 249}, {251, 253}, {255, 258}, {259, 260}, {268, 272}, {282, 283}, {285, 286}, {291, 292}, {311, 312}, {315, 316}, {318, 320}, {322, 324}, {327, 328}, {331, 332}, {333, 334}, {337, 338}, {339, 340}, {342, 343}, {352, 355}, {356, 359}}
Gives also the start-ends of single-element sublists:
pos = Accumulate @ Partition[{1}~Join~(Length /@ Split @ ListA), 2, 1]
{{1, 10}, {11, 13}, {14, 16}, {17, 17}, {18, 48}, {49, 49}, {50, 50}, {51, 88}, {89, 99}, {100, 249}, {250, 250}, {251, 253}, {254, 254}, {255, 258}, {259, 260}, {261, 261}, {262, 262}, {263, 263}, {264, 264}, {265, 265}, {266, 266}, {267, 267}, {268, 272}, {273, 273}, {274, 274}, {275, 275}, {276, 276}, {277, 277}, {278, 278}, {279, 279}, {280, 280}, {281, 281}, {282, 283}, {284, 284}, {285, 286}, {287, 287}, {288, 288}, {289, 289}, {290, 290}, {291, 292}, {293, 293}, {294, 294}, {295, 295}, {296, 296}, {297, 297}, {298, 298}, {299, 299}, {300, 300}, {301, 301}, {302, 302}, {303, 303}, {304, 304}, {305, 305}, {306, 306}, {307, 307}, {308, 308}, {309, 309}, {310, 310}, {311, 312}, {313, 313}, {314, 314}, {315, 316}, {317, 317}, {318, 320}, {321, 321}, {322, 324}, {325, 325}, {326, 326}, {327, 328}, {329, 329}, {330, 330}, {331, 332}, {333, 334}, {335, 335}, {336, 336}, {337, 338}, {339, 340}, {341, 341}, {342, 343}, {344, 344}, {345, 345}, {346, 346}, {347, 347}, {348, 348}, {349, 349}, {350, 350}, {351, 351}, {352, 355}, {356, 359}, {360, 360}}
Ignoring subsequences of length 1:
Select[pos, Differences@# != {0} &]
{{1, 10}, {11, 13}, {14, 16}, {18, 48}, {51, 88}, {89, 99}, {100, 249}, {251, 253}, {255, 258}, {259, 260}, {268, 272}, {282, 283}, {285, 286}, {291, 292}, {311, 312}, {315, 316}, {318, 320}, {322, 324}, {327, 328}, {331, 332}, {333, 334}, {337, 338}, {339, 340}, {342, 343}, {352, 355}, {356, 359}}
Alternatively:
pos = MinMax /@ SplitBy[MapIndexed[List, ListA], First][[All, All, 2]]
Select[pos, #[[1]] != #[[2]] &]