Skip to main content
replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link

APL, 8 5 bytes

+/∊+⍨

This is a monadic function train that accepts an array and returns a boolean (0/1 in APL). It uses the same algorithm as xnor's Python 3 answeranswer.

Explanation:

   +⍨  ⍝ Double the input (+⍨x is the same as x+x)
  ∊    ⍝ Test the membership of
+/     ⍝ The sum of the input

Try it online

Saved 3 bytes thanks to Dennis!

APL, 8 5 bytes

+/∊+⍨

This is a monadic function train that accepts an array and returns a boolean (0/1 in APL). It uses the same algorithm as xnor's Python 3 answer.

Explanation:

   +⍨  ⍝ Double the input (+⍨x is the same as x+x)
  ∊    ⍝ Test the membership of
+/     ⍝ The sum of the input

Try it online

Saved 3 bytes thanks to Dennis!

APL, 8 5 bytes

+/∊+⍨

This is a monadic function train that accepts an array and returns a boolean (0/1 in APL). It uses the same algorithm as xnor's Python 3 answer.

Explanation:

   +⍨  ⍝ Double the input (+⍨x is the same as x+x)
  ∊    ⍝ Test the membership of
+/     ⍝ The sum of the input

Try it online

Saved 3 bytes thanks to Dennis!

added 55 characters in body
Source Link
Alex A.
  • 24.8k
  • 5
  • 39
  • 120

APL, 88 5 bytes

⊢∊⍨2÷⍨++/∊+⍨

This is a monadic function train that accepts an array and returns a boolean (0/1 in APL). It uses the same algorithm as xnor's Python 3 answer.

Explanation:

   +⍨   Double +/the input (+⍨x Sumis the input
same as x+x)
  2÷⍨DivideTest bythe 2membership of
⊢∊⍨+/      The sum Testof forthe membershipinput

Try it onlineTry it online

Saved 3 bytes thanks to Dennis!

APL, 8 bytes

⊢∊⍨2÷⍨+/

This is a monadic function train that accepts an array and returns a boolean (0/1 in APL). It uses the same algorithm as xnor's Python 3 answer.

Explanation:

       +/   Sum the input
    2÷⍨Divide by 2
⊢∊⍨        Test for membership

Try it online

APL, 8 5 bytes

+/∊+⍨

This is a monadic function train that accepts an array and returns a boolean (0/1 in APL). It uses the same algorithm as xnor's Python 3 answer.

Explanation:

   +⍨   Double the input (+⍨x is the same as x+x)
  Test the membership of
+/      The sum of the input

Try it online

Saved 3 bytes thanks to Dennis!

Source Link
Alex A.
  • 24.8k
  • 5
  • 39
  • 120

APL, 8 bytes

⊢∊⍨2÷⍨+/

This is a monadic function train that accepts an array and returns a boolean (0/1 in APL). It uses the same algorithm as xnor's Python 3 answer.

Explanation:

       +/  ⍝ Sum the input
    2÷⍨    ⍝ Divide by 2
⊢∊⍨       ⍝ Test for membership

Try it online