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

Commonmark migration
Source Link

#CJam , 11 bytes

CJam , 11 bytes

Thanks to @Dennis for two corrections and one byte off!

{1+_2f%1#<}

This is a code block (equivalent to a function; allowed by default) that expects the input array on the stack, and leaves the output array on the stack.

Try it online!

###Explanation

Explanation

{ } e# define code block
 1+ e# attach 1 at the end of the array
 _ e# duplicate
 2f% e# modulo 2 of each entry
 1# e# find index of first occurrence of 1
 < e# slice before

#CJam , 11 bytes

Thanks to @Dennis for two corrections and one byte off!

{1+_2f%1#<}

This is a code block (equivalent to a function; allowed by default) that expects the input array on the stack, and leaves the output array on the stack.

Try it online!

###Explanation

{ } e# define code block
 1+ e# attach 1 at the end of the array
 _ e# duplicate
 2f% e# modulo 2 of each entry
 1# e# find index of first occurrence of 1
 < e# slice before

CJam , 11 bytes

Thanks to @Dennis for two corrections and one byte off!

{1+_2f%1#<}

This is a code block (equivalent to a function; allowed by default) that expects the input array on the stack, and leaves the output array on the stack.

Try it online!

Explanation

{ } e# define code block
 1+ e# attach 1 at the end of the array
 _ e# duplicate
 2f% e# modulo 2 of each entry
 1# e# find index of first occurrence of 1
 < e# slice before
edited body
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382

#CJam, 11 bytes

Thanks to @Dennis for two corrections and one byte off!

{1+_2f%1#<}

This is a code block (equivalent to a function; allowed by default) that expects the input array inon the stack, and leaves the output array inon the stack.

Try it online!

###Explanation

{ } e# define code block
 1+ e# attach 1 at the end of the array
 _ e# duplicate
 2f% e# modulo 2 of each entry
 1# e# find index of first occurrence of 1
 < e# slice before

#CJam, 11 bytes

Thanks to @Dennis for two corrections and one byte off!

{1+_2f%1#<}

This is a code block (equivalent to a function; allowed by default) that expects the input array in the stack, and leaves the output array in the stack.

Try it online!

###Explanation

{ } e# define code block
 1+ e# attach 1 at the end of the array
 _ e# duplicate
 2f% e# modulo 2 of each entry
 1# e# find index of first occurrence of 1
 < e# slice before

#CJam, 11 bytes

Thanks to @Dennis for two corrections and one byte off!

{1+_2f%1#<}

This is a code block (equivalent to a function; allowed by default) that expects the input array on the stack, and leaves the output array on the stack.

Try it online!

###Explanation

{ } e# define code block
 1+ e# attach 1 at the end of the array
 _ e# duplicate
 2f% e# modulo 2 of each entry
 1# e# find index of first occurrence of 1
 < e# slice before
deleted 93 characters in body
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382

#CJam, 1211 bytes

Thanks to @Dennis for a correction.two corrections and one byte off!

{~1]_2f%1#<1+_2f%1#<}

This is a code block (equivalent to a function; allowed by default) that expects the input array in the stack, and leaves the output array in the stack.

Try it online! Try it online!

###Explanation

{ } e# define code block
 ~ e# dump array contents
 1 1+ e# pushattach 1
 ]  e# pack into array: original array with anat additionalthe 1end atof the endarray
 _ e# duplicate
 2f% e# modulo 2 of each entry
 1# e# find index of first occurrence of 1
 < e# slice before

#CJam, 12 bytes

Thanks to @Dennis for a correction.

{~1]_2f%1#<}

This is a code block (equivalent to a function; allowed by default) that expects the input array in the stack, and leaves the output array in the stack.

Try it online!

###Explanation

{ } e# define code block
 ~ e# dump array contents
 1  e# push 1
 ]  e# pack into array: original array with an additional 1 at the end
 _ e# duplicate
 2f% e# modulo 2 of each entry
 1# e# find index of first occurrence of 1
 < e# slice before

#CJam, 11 bytes

Thanks to @Dennis for two corrections and one byte off!

{1+_2f%1#<}

This is a code block (equivalent to a function; allowed by default) that expects the input array in the stack, and leaves the output array in the stack.

Try it online!

###Explanation

{ } e# define code block
 1+ e# attach 1 at the end of the array
 _ e# duplicate
 2f% e# modulo 2 of each entry
 1# e# find index of first occurrence of 1
 < e# slice before
Post Undeleted by Luis Mendo
added 229 characters in body
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382
Loading
Post Deleted by Luis Mendo
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382
Loading

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