Offset Partition with only one remainder element
Partition[{a, b, c, d, e, f, g}, 4, 2, {1, -2}, {}]
{{a, b, c, d}, {c, d, e, f}, {e, f, g}}
Partition[{a, b, c, d, e, f, g}, 5, 2, {1, -2}, {}]
{{a, b, c, d, e}, {c, d, e, f, g}}
In general, a function that works for varying partition and offset size and on lists of unknown length:
ClearAll[pF]
pF = Partition[##, {1, -#3}, {}] &;
Examples:
pF[{a, b, c, d, e, f, g}, 4, 2]
{{a, b, c, d}, {c, d, e, f}, {e, f, g}}
pF[{a, b, c, d, e, f, g}, 4, 3]
{{a, b, c, d}, {d, e, f, g}}
pF[{a, b, c, d, e, f, g}, 5, 2]
{{a, b, c, d, e}, {c, d, e, f, g}}
pF[{a, b, c, d, e, f, g}, 5, 3]
{{a, b, c, d, e}, {d, e, f, g}}
Most@Partition[list, 4, 2, 1, {}]
{{a, b, c, d}, {c, d, e, f}, {e, f, g}}
An alternative:
Partition[list, UpTo[4], 2, {1, 3}]
{{a, b, c, d}, {c, d, e, f}, {e, f, g}}
Edit: For the more general case, I can't see an easy way to do it directly from Partition
. The simplest way I can see (though not necessarily the fastest or most elegant) is, as you suggested, deleting the sublists you don't want.
SeedRandom[1]
n = RandomInteger[{5, 20}];
list = Array[a, n];
offset = RandomInteger[{1, n}];
maxlength = RandomInteger[{offset, n}];
DeleteDuplicatesBy[Partition[list, UpTo[maxlength], offset], Last]
(* {{a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11]},
{a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14]},
{a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15], a[16], a[17]},
{a[10], a[11], a[12], a[13], a[14], a[15], a[16], a[17], a[18]}}
Since DeleteDuplicatesBy
will keep the first duplicate, it will only delete the sublists at the end that end with the final element of the list.