#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.
###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.
###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.
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 inon the stack, and leaves the output array inon the stack.
###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.
###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.
###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, 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.
###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.
###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.
###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