Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

added 315 characters in body
Source Link
Dennis
  • 211.7k
  • 41
  • 380
  • 830

Jelly, 5 bytes

Ḃœp1ḢḂœp8Ḣ

Try it online! Try it online! or verify all test cases verify all test cases.

How it works

Ḃœp8Ḣ Main link. Argument: A (array)
Ḃ Bit; yield 1 for odd integers, 0 for even ones.
 8 Yield A.
 œp Partition A, splitting at 1's in the bit array.
 This yields a 2D array of runs of even integers.
 Ḣ Head; extract the first chunk.

Jelly, 5 bytes

Ḃœp8Ḣ

Try it online! or verify all test cases.

How it works

Ḃœp8Ḣ Main link. Argument: A (array)
Ḃ Bit; yield 1 for odd integers, 0 for even ones.
 8 Yield A.
 œp Partition A, splitting at 1's in the bit array.
 This yields a 2D array of runs of even integers.
 Ḣ Head; extract the first chunk.
Source Link
Dennis
  • 211.7k
  • 41
  • 380
  • 830

AltStyle によって変換されたページ (->オリジナル) /