Skip to main content
Code shortening
Source Link
ErikF
  • 4.8k
  • 9
  • 11

C (gcc) with -m32 and -mllm, 94 8888 87 bytes

  • -6 thanks to ceilingcat

32-bit mode used to make bit-twiddling of pointers easier.

As C doesn't have any list primitive, I implemented a tagged value list (lists stored as an item have the least significant bit set.) The function simply gets the total length of the current list and checks to see if any sublist has a longer length.

f(l,m,i)int*l,*m;{for(m=l,i=0;l;l=l[1])i++;for(;m;m=m[1])*m&1?i=fmax(f(*m&~1*m^1),i):0;l=i;} 

Try it online!Try it online!

Ungolfed:

f(l,m,i)int*l,*m;{ for(m=l,i=0;l;l=l[1]) i++; // Get length of current list for(;m;m=m[1]) *m&1? // Is this a sublist? i=fmax(f(*m&~1*m^1),i): // Is the sublist longer? 0; l=i; } 

C (gcc) with -m32 and -ml, 94 88 bytes

  • -6 thanks to ceilingcat

32-bit mode used to make bit-twiddling of pointers easier.

As C doesn't have any list primitive, I implemented a tagged value list (lists stored as an item have the least significant bit set.) The function simply gets the total length of the current list and checks to see if any sublist has a longer length.

f(l,m,i)int*l,*m;{for(m=l,i=0;l;l=l[1])i++;for(;m;m=m[1])*m&1?i=fmax(f(*m&~1),i):0;l=i;} 

Try it online!

Ungolfed:

f(l,m,i)int*l,*m;{ for(m=l,i=0;l;l=l[1]) i++; // Get length of current list for(;m;m=m[1]) *m&1? // Is this a sublist? i=fmax(f(*m&~1),i): // Is the sublist longer? 0; l=i; } 

C (gcc) with -m32 and -lm, 94 88 87 bytes

  • -6 thanks to ceilingcat

32-bit mode used to make bit-twiddling of pointers easier.

As C doesn't have any list primitive, I implemented a tagged value list (lists stored as an item have the least significant bit set.) The function simply gets the total length of the current list and checks to see if any sublist has a longer length.

f(l,m,i)int*l,*m;{for(m=l,i=0;l;l=l[1])i++;for(;m;m=m[1])*m&1?i=fmax(f(*m^1),i):0;l=i;} 

Try it online!

Ungolfed:

f(l,m,i)int*l,*m;{ for(m=l,i=0;l;l=l[1]) i++; // Get length of current list for(;m;m=m[1]) *m&1? // Is this a sublist? i=fmax(f(*m^1),i): // Is the sublist longer? 0; l=i; } 
Code shortening
Source Link
ErikF
  • 4.8k
  • 9
  • 11

C (gcc) with -m32 and -ml, 9494 88 bytes

  • -6 thanks to ceilingcat

32-bit mode used to make bit-twiddling of pointers easier.

As C doesn't have any list primitive, I implemented a tagged value list (lists stored as an item have the least significant bit set.) The function simply gets the total length of the current list and checks to see if any sublist has a longer length.

f(l,m,i,j)int*l,*m;{for(m=l,i=j=0;l;l=l[1]i=0;l;l=l[1])i++;for(;m;m=m[1])*m&1?i=i=fmax(j=ff(*m&~1))>i?j:,i):0;j=i;0;l=i;} 

Try it online!Try it online!

Ungolfed:

f(l,m,i,j)int*l,*m;{ for(m=l,i=j=0;l;l=l[1]i=0;l;l=l[1]) i++; // Get length of current list for(;m;m=m[1]) *m&1? // Is this a sublist? i=i=fmax(j=ff(*m&~1))>i?j:,i): // Is the sublist longer? 0; j=i;l=i; } 

C (gcc) with -m32, 94 bytes

32-bit mode used to make bit-twiddling of pointers easier.

As C doesn't have any list primitive, I implemented a tagged value list (lists stored as an item have the least significant bit set.) The function simply gets the total length of the current list and checks to see if any sublist has a longer length.

f(l,m,i,j)int*l,*m;{for(m=l,i=j=0;l;l=l[1])i++;for(;m;m=m[1])*m&1?i=(j=f(*m&~1))>i?j:i:0;j=i;} 

Try it online!

Ungolfed:

f(l,m,i,j)int*l,*m;{ for(m=l,i=j=0;l;l=l[1]) i++; // Get length of current list for(;m;m=m[1]) *m&1? // Is this a sublist? i=(j=f(*m&~1))>i?j:i: // Is the sublist longer? 0; j=i; } 

C (gcc) with -m32 and -ml, 94 88 bytes

  • -6 thanks to ceilingcat

32-bit mode used to make bit-twiddling of pointers easier.

As C doesn't have any list primitive, I implemented a tagged value list (lists stored as an item have the least significant bit set.) The function simply gets the total length of the current list and checks to see if any sublist has a longer length.

f(l,m,i)int*l,*m;{for(m=l,i=0;l;l=l[1])i++;for(;m;m=m[1])*m&1?i=fmax(f(*m&~1),i):0;l=i;} 

Try it online!

Ungolfed:

f(l,m,i)int*l,*m;{ for(m=l,i=0;l;l=l[1]) i++; // Get length of current list for(;m;m=m[1]) *m&1? // Is this a sublist? i=fmax(f(*m&~1),i): // Is the sublist longer? 0; l=i; } 
Source Link
ErikF
  • 4.8k
  • 9
  • 11

C (gcc) with -m32, 94 bytes

32-bit mode used to make bit-twiddling of pointers easier.

As C doesn't have any list primitive, I implemented a tagged value list (lists stored as an item have the least significant bit set.) The function simply gets the total length of the current list and checks to see if any sublist has a longer length.

f(l,m,i,j)int*l,*m;{for(m=l,i=j=0;l;l=l[1])i++;for(;m;m=m[1])*m&1?i=(j=f(*m&~1))>i?j:i:0;j=i;} 

Try it online!

Ungolfed:

f(l,m,i,j)int*l,*m;{ for(m=l,i=j=0;l;l=l[1]) i++; // Get length of current list for(;m;m=m[1]) *m&1? // Is this a sublist? i=(j=f(*m&~1))>i?j:i: // Is the sublist longer? 0; j=i; }