@ido.r

I was about to post your recent point, that you can't use functions or loops, to @john.c.

I'm a strong advocate of an interface function for recursion, but alas that is out here.

Let me walk through an idea as it evolved while I was out doing stuff, which first explores ways to at least find the answer, then fold that into a compliant solution that seems to fit the requirements.

First, if we could use loops, this gets the answer as best I can test in short time:

Code:

int lenseries1( const int *a, int size )
{
if ( size < 1 ) return 0;
int len = lenseries1( a + 1, size - 1 );
int val = a[ 0 ];
int seqcount{ 1 };
for( int pos = 1 ; pos < size; ++pos )
{
if ( val >= a[ pos ] ) break;
val = a[ pos ];
++seqcount;
}
if ( seqcount > len ) return seqcount;
return len;
}

With a loop being a disqualifier, I decided to try an experimental version that violates the rules to prove a hunch:

Code:

int lenseries4( const int *a, int sz, int curcount, int maxcount )
{
if ( sz < 2 ) return maxcount;
bool is_series = a[ 0 ] < a[ 1 ];
if ( is_series ) curcount++;
if ( curcount > maxcount ) maxcount = curcount;
if ( !is_series ) curcount = 1;
maxcount = lenseries4( a+1, sz-1, curcount, maxcount );
return maxcount;
}
int lenseries( const int *a, int sz )
{
int maxcount{0};
return lenseries4( a, sz, 1, maxcount );
}

This shows a need to preserve "maxcount" ongoing, but we don't have quite enough parameters.

So, unless this is considered "cheating", I wrapped the values into the size parameter using some simple "bit fiddling", which assumes the max size will be < 255 (but variations are certainly possible to expand that limit)

Code:

const int mask_h{ 0x00ff0000 };
const int mask_l{ 0x0000ff00 };
const int mask_s{ 0x000000ff };
int lenseries5( const int *a, int sz )
{
int size = sz & mask_s;
int curcount = (sz & mask_l) >> 8;
int maxcount = (sz & mask_h) >> 16;
if ( curcount == 0 ) curcount = 1;
if ( size < 2 ) return maxcount;
bool is_series = a[ 0 ] < a[ 1 ];
if ( is_series ) curcount++;
if ( curcount > maxcount ) maxcount = curcount;
if ( !is_series ) curcount = 1;
sz = ( size - 1 ) | ( curcount << 8 ) | ( maxcount << 16 );
return lenseries5( a+1, sz );
}

So here is the same plan as the previous (lenseries4 and interface function), but this uses the size integer to pack in size, curcount and maxsize, using the return to preserve maxsize as found going in.

I've written this in over-simplified style for illustration.

See if it violates any rules or the spirit of the restrictions.