Skip to main content
deleted 5 characters in body
Source Link
Jonah
  • 33.8k
  • 4
  • 40
  • 94

J, 32 bytes

[:;(,/:,&(#\))&(<;.1~2~:/\'_'&,)

Attempt This Online!

The 2nd part of this is the only interesting insight:

  • [:;...&(<;.1~2~:/\'_'&,) This is the preprocessing step that breaks the lists down into the grouped sections. A standard J idiom which is unfortunately a bit verbose in J. I could save two bytes by using integers instead of strings as input.
  • ,/:,&(#\) The main logic. Since we can't zip uneven lists in J using ,., we just cat the lists , and then sort them /: by 1..n catted with 1..m (where n and m are the two list lengths). This works because sort is stable.

J, 32 bytes

[:;(,/:,&(#\))&(<;.1~2~:/\'_'&,)

Attempt This Online!

The 2nd part of this is the only interesting insight:

  • [:;...&(<;.1~2~:/\'_'&,) This is the preprocessing step that breaks the lists down into the grouped sections. A standard J idiom which is unfortunately a bit verbose in J. I could save two bytes by using integers instead of strings as input.
  • ,/:,&(#\) The main logic. Since we can't zip uneven lists in J using ,., we just cat the lists , and then sort them /: by 1..n catted with 1..m (where n and m are the two list lengths). This works because sort is stable.

J, 32 bytes

[:;(,/:,&(#\))&(<;.1~2~:/\'_'&,)

Attempt This Online!

The 2nd part of this is the only interesting insight:

  • [:;...&(<;.1~2~:/\'_'&,) This is the preprocessing step that breaks the lists down into the grouped sections. A standard J idiom which is unfortunately a bit verbose. I could save two bytes by using integers instead of strings as input.
  • ,/:,&(#\) The main logic. Since we can't zip uneven lists in J using ,., we just cat the lists , and then sort them /: by 1..n catted with 1..m (where n and m are the two list lengths). This works because sort is stable.
deleted 613 characters in body
Source Link
Jonah
  • 33.8k
  • 4
  • 40
  • 94

J, 932 bytes

[:;(,/:,&(#\)

Attempt This Online!

Since we can't zip uneven lists in J using ,., we just cat the lists , and then sort them /: by 1..n catted with 1..m (where n and m are the two list lengths). This works because sort is stable.

J, 12 bytes

a:-)&(<;.~,@|1~2~:@/\'_'&,:)

Attempt This Online!Attempt This Online!

We can take the input as lists (boxed lists in J, by necessity), and the problem reduces to zipping listsThe 2nd part of unequal length. Thisthis is not allowed by "stitch" ,. (J's zip), but you can combined to lists with ,: and J will pad the extra slots with blanks.only interesting insight:

After that we can imitate zip by doing a transpose, flatten, and removing empties.

  • [:;...&(<;.1~2~:/\'_'&,) This is the preprocessing step that breaks the lists down into the grouped sections. A standard J idiom which is unfortunately a bit verbose in J. I could save two bytes by using integers instead of strings as input.
  • ,/:,&(#\) The main logic. Since we can't zip uneven lists in J using ,., we just cat the lists , and then sort them /: by 1..n catted with 1..m (where n and m are the two list lengths). This works because sort is stable.

J, 9 bytes

,/:,&(#\)

Attempt This Online!

Since we can't zip uneven lists in J using ,., we just cat the lists , and then sort them /: by 1..n catted with 1..m (where n and m are the two list lengths). This works because sort is stable.

J, 12 bytes

a:-.~,@|:@,:

Attempt This Online!

We can take the input as lists (boxed lists in J, by necessity), and the problem reduces to zipping lists of unequal length. This is not allowed by "stitch" ,. (J's zip), but you can combined to lists with ,: and J will pad the extra slots with blanks.

After that we can imitate zip by doing a transpose, flatten, and removing empties.

J, 32 bytes

[:;(,/:,&(#\))&(<;.1~2~:/\'_'&,)

Attempt This Online!

The 2nd part of this is the only interesting insight:

  • [:;...&(<;.1~2~:/\'_'&,) This is the preprocessing step that breaks the lists down into the grouped sections. A standard J idiom which is unfortunately a bit verbose in J. I could save two bytes by using integers instead of strings as input.
  • ,/:,&(#\) The main logic. Since we can't zip uneven lists in J using ,., we just cat the lists , and then sort them /: by 1..n catted with 1..m (where n and m are the two list lengths). This works because sort is stable.
added 598 characters in body
Source Link
Jonah
  • 33.8k
  • 4
  • 40
  • 94

J, 129 bytes

,/:,&(#\)

Attempt This Online!

Since we can't zip uneven lists in J using ,., we just cat the lists , and then sort them /: by 1..n catted with 1..m (where n and m are the two list lengths). This works because sort is stable.

J, 12 bytes

a:-.~,@|:@,:

Attempt This Online!

We can take the input as lists (boxed lists in J, by necessity), and the problem reduces to zipping lists of unequal length. This is not allowed by "stitch" ,. (J's zip), but you can combined to lists with ,: and J will pad the extra slots with blanks.

After that we can imitate zip by doing a transpose, flatten, and removing empties.

J, 12 bytes

a:-.~,@|:@,:

Attempt This Online!

We can take the input as lists (boxed lists in J, by necessity), and the problem reduces to zipping lists of unequal length. This is not allowed by "stitch" ,. (J's zip), but you can combined to lists with ,: and J will pad the extra slots with blanks.

After that we can imitate zip by doing a transpose, flatten, and removing empties.

J, 9 bytes

,/:,&(#\)

Attempt This Online!

Since we can't zip uneven lists in J using ,., we just cat the lists , and then sort them /: by 1..n catted with 1..m (where n and m are the two list lengths). This works because sort is stable.

J, 12 bytes

a:-.~,@|:@,:

Attempt This Online!

We can take the input as lists (boxed lists in J, by necessity), and the problem reduces to zipping lists of unequal length. This is not allowed by "stitch" ,. (J's zip), but you can combined to lists with ,: and J will pad the extra slots with blanks.

After that we can imitate zip by doing a transpose, flatten, and removing empties.

Source Link
Jonah
  • 33.8k
  • 4
  • 40
  • 94
Loading