Skip to main content
added 400 characters in body
Source Link
Martin Ender
  • 197.2k
  • 67
  • 447
  • 975

CJam, 10 8 bytes

l2/{)-}%

[Test it here.][1]

Explanation

This is a very simple solution: in each pair, remove all instances of the last character. Repeated digits and unpaired trailing digits will be removed, as will be the second digit in any pair of unequal digits:

"0"  --> ""
"1"  --> ""
"00" --> ""
"01" --> "0"
"10" --> "1"
"11" --> ""

This leaves only the digits we're looking for. Here's how the code computes this:

l     e# Read input.
2/    e# Split into pairs. Odd inputs will yield a single-character string at the end.
{     e# Map this block over the pairs...
  )-  e#   Removee# all copies ofPull the last character fromoff the string. "11" 
 and "00" as
-   e#   e#Remove all occurrences wellof asthat single-character stringsfrom willthe turnremainder into(which emptyis strings.either
      e#   "10"an andempty "01"string willto turnbegin intowith "1"or anda "0"single-digit string).
}%

When the list is auto-printed at the end of the program, the empty strings are simply omitted.

[1]: http://cjam.aditsu.net/#code=l2%2F%7B)-%7D%25&input=1011101010

CJam, 10 8 bytes

l2/{)-}%

[Test it here.][1]

Explanation

l     e# Read input.
2/    e# Split into pairs. Odd inputs will yield a single-character string at the end.
{     e# Map this block over the pairs...
  )-  e#   Remove all copies of the last character from the string. "11" and "00" as
      e#   well as single-character strings will turn into empty strings.
      e#   "10" and "01" will turn into "1" and "0".
}%

When the list is auto-printed at the end of the program, the empty strings are simply omitted.

[1]: http://cjam.aditsu.net/#code=l2%2F%7B)-%7D%25&input=1011101010

CJam, 10 8 bytes

l2/{)-}%

[Test it here.][1]

Explanation

This is a very simple solution: in each pair, remove all instances of the last character. Repeated digits and unpaired trailing digits will be removed, as will be the second digit in any pair of unequal digits:

"0"  --> ""
"1"  --> ""
"00" --> ""
"01" --> "0"
"10" --> "1"
"11" --> ""

This leaves only the digits we're looking for. Here's how the code computes this:

l     e# Read input.
2/    e# Split into pairs. Odd inputs will yield a single-character string at the end.
{     e# Map this block over the pairs...
  )   e#   Pull the last character off the string. 
  -   e#   Remove all occurrences of that character from the remainder (which is either
      e#   an empty string to begin with or a single-digit string).
}%

When the list is auto-printed at the end of the program, the empty strings are simply omitted.

[1]: http://cjam.aditsu.net/#code=l2%2F%7B)-%7D%25&input=1011101010

added 3 characters in body
Source Link
Martin Ender
  • 197.2k
  • 67
  • 447
  • 975

CJam, 1010 8 bytes

l2/{)-},:c%

[Test it here.][1]

Explanation

l     e# Read input.
2/    e# Split into pairs. Odd inputs will yield a single-character string at the end.
{     e# Map this block over the pairs...
  )-  e#   Remove all copies of the last character from the string. "11" and "00" as
      e#   well as single-character strings will turn into empty strings.
      e#   "10" and "01" will turn into "1" and "0".
}%

When the list is auto-printed at the end of the program, the empty strings are simply omitted.

[1]: http://cjam.aditsu.net/#code=l2%2F%7B)-%7D%2C%3Ac&input=1011101010%7D%25&input=1011101010

CJam, 10 bytes

l2/{)-},:c

[Test it here.][1]

[1]: http://cjam.aditsu.net/#code=l2%2F%7B)-%7D%2C%3Ac&input=1011101010

CJam, 10 8 bytes

l2/{)-}%

[Test it here.][1]

Explanation

l     e# Read input.
2/    e# Split into pairs. Odd inputs will yield a single-character string at the end.
{     e# Map this block over the pairs...
  )-  e#   Remove all copies of the last character from the string. "11" and "00" as
      e#   well as single-character strings will turn into empty strings.
      e#   "10" and "01" will turn into "1" and "0".
}%

When the list is auto-printed at the end of the program, the empty strings are simply omitted.

[1]: http://cjam.aditsu.net/#code=l2%2F%7B)-%7D%25&input=1011101010

Source Link
Martin Ender
  • 197.2k
  • 67
  • 447
  • 975

CJam, 10 bytes

l2/{)-},:c

[Test it here.][1]

[1]: http://cjam.aditsu.net/#code=l2%2F%7B)-%7D%2C%3Ac&input=1011101010