Skip to main content
Don't need signum
Source Link
Business Cat
  • 9.2k
  • 1
  • 17
  • 37

CJam, 1818 17 bytes

q~_,2\m*\f.*::+#)g

Try it online!Try it online!

Explanation

q~                  e# Read and eval input.
  _,                e# Duplicate the money list and take its length.
    2\m*            e# Take the (length)th Cartesian power of [0 1].
        \f.*        e# Element-wise multiplication of each set of 0's and 1's with the money
                    e#   list. This is essentially the powerset, but with 0s instead of 
                    e#   missing elements.
            ::+     e# Sum each set.
               #    e# Find the index of the desired amount in the list. (-1 if not found)
                )g   e# Increment and signum. (-1 => 0 (falsy), anything else => 1nonzero (truthy)

CJam, 18 bytes

q~_,2\m*\f.*::+#)g

Try it online!

Explanation

q~                  e# Read and eval input.
  _,                e# Duplicate the money list and take its length.
    2\m*            e# Take the (length)th Cartesian power of [0 1].
        \f.*        e# Element-wise multiplication of each set of 0's and 1's with the money
                    e#   list. This is essentially the powerset, but with 0s instead of 
                    e#   missing elements.
            ::+     e# Sum each set.
               #    e# Find the index of the desired amount in the list. (-1 if not found)
                )g  e# Increment and signum. (-1 => 0, anything else => 1)

CJam, 18 17 bytes

q~_,2\m*\f.*::+#)

Try it online!

Explanation

q~                  e# Read and eval input.
  _,                e# Duplicate the money list and take its length.
    2\m*            e# Take the (length)th Cartesian power of [0 1].
        \f.*        e# Element-wise multiplication of each set of 0's and 1's with the money
                    e#   list. This is essentially the powerset, but with 0s instead of 
                    e#   missing elements.
            ::+     e# Sum each set.
               #    e# Find the index of the desired amount in the list. (-1 if not found)
                )   e# Increment. -1 => 0 (falsy), anything else => nonzero (truthy)
added 670 characters in body
Source Link
Business Cat
  • 9.2k
  • 1
  • 17
  • 37

CJam, 18 bytes

q~_,2\m*\f.*::+#)g

Try it online!

Explanation

q~                  e# Read and eval input.
  _,                e# Duplicate the money list and take its length.
    2\m*            e# Take the (length)th Cartesian power of [0 1].
        \f.*        e# Element-wise multiplication of each set of 0's and 1's with the money
                    e#   list. This is essentially the powerset, but with 0s instead of 
                    e#   missing elements.
            ::+     e# Sum each set.
               #    e# Find the index of the desired amount in the list. (-1 if not found)
                )g  e# Increment and signum. (-1 => 0, anything else => 1)

CJam, 18 bytes

q~_,2\m*\f.*::+#)g

Try it online!

CJam, 18 bytes

q~_,2\m*\f.*::+#)g

Try it online!

Explanation

q~                  e# Read and eval input.
  _,                e# Duplicate the money list and take its length.
    2\m*            e# Take the (length)th Cartesian power of [0 1].
        \f.*        e# Element-wise multiplication of each set of 0's and 1's with the money
                    e#   list. This is essentially the powerset, but with 0s instead of 
                    e#   missing elements.
            ::+     e# Sum each set.
               #    e# Find the index of the desired amount in the list. (-1 if not found)
                )g  e# Increment and signum. (-1 => 0, anything else => 1)
Source Link
Business Cat
  • 9.2k
  • 1
  • 17
  • 37

CJam, 18 bytes

q~_,2\m*\f.*::+#)g

Try it online!