Skip to main content

#R, 3936 bytes

R, 39 36 bytes

w<-function(s)!any(outer(s,s,'+')%in%s)

Call as w(s), where s is the set (actually vector) of values. Here'sHere is the output for some test cases:

> w(numeric(0)) # The empty set
[1] TRUE
> w(0)
[1] FALSE
> w(1)
[1] TRUE
> w(c(1, 5, 7))
[1] TRUE
> w(c(2, 4, 9, 13))
[1] FALSE

Where c()c() is the concatenation function that takes a bunch of values and makes it a vector.

EDIT: Making it an anonymous function to save 3 bytes, thanks to @MickyT.

function(s)!any(outer(s,s,'+')%in%s)

#R, 3936 bytes

w<-function(s)!any(outer(s,s,'+')%in%s)

Call as w(s), where s is the set (actually vector) of values. Here's the output for some test cases:

> w(numeric(0)) # The empty set
[1] TRUE
> w(0)
[1] FALSE
> w(1)
[1] TRUE
> w(c(1, 5, 7))
[1] TRUE
> w(c(2, 4, 9, 13))
[1] FALSE

Where c() is the concatenation function that takes a bunch of values and makes it a vector.

EDIT: Making it an anonymous function to save 3 bytes, thanks to @MickyT.

function(s)!any(outer(s,s,'+')%in%s)

R, 39 36 bytes

w<-function(s)!any(outer(s,s,'+')%in%s)

Call as w(s), where s is the set (actually vector) of values. Here is the output for some test cases:

> w(numeric(0)) # The empty set
[1] TRUE
> w(0)
[1] FALSE
> w(1)
[1] TRUE
> w(c(1, 5, 7))
[1] TRUE
> w(c(2, 4, 9, 13))
[1] FALSE

Where c() is the concatenation function that takes a bunch of values and makes it a vector.

EDIT: Making it an anonymous function to save 3 bytes, thanks to @MickyT.

function(s)!any(outer(s,s,'+')%in%s)
Saving 3 bytes
Source Link
ConMan
  • 213
  • 1
  • 3

#R, 393936 bytes

w<-function(s)!any(outer(s,s,'+')%in%s)

Call as w(s), where s is the set (actually vector) of values. Here's the output for some test cases:

> w(numeric(0)) # The empty set
[1] TRUE
> w(0)
[1] FALSE
> w(1)
[1] TRUE
> w(c(1, 5, 7))
[1] TRUE
> w(c(2, 4, 9, 13))
[1] FALSE

Where c() is the concatenation function that takes a bunch of values and makes it a vector.

EDIT: Making it an anonymous function to save 3 bytes, thanks to @MickyT.

function(s)!any(outer(s,s,'+')%in%s)

#R, 39 bytes

w<-function(s)!any(outer(s,s,'+')%in%s)

Call as w(s), where s is the set (actually vector) of values. Here's the output for some test cases:

> w(numeric(0)) # The empty set
[1] TRUE
> w(0)
[1] FALSE
> w(1)
[1] TRUE
> w(c(1, 5, 7))
[1] TRUE
> w(c(2, 4, 9, 13))
[1] FALSE

Where c() is the concatenation function that takes a bunch of values and makes it a vector.

#R, 3936 bytes

w<-function(s)!any(outer(s,s,'+')%in%s)

Call as w(s), where s is the set (actually vector) of values. Here's the output for some test cases:

> w(numeric(0)) # The empty set
[1] TRUE
> w(0)
[1] FALSE
> w(1)
[1] TRUE
> w(c(1, 5, 7))
[1] TRUE
> w(c(2, 4, 9, 13))
[1] FALSE

Where c() is the concatenation function that takes a bunch of values and makes it a vector.

EDIT: Making it an anonymous function to save 3 bytes, thanks to @MickyT.

function(s)!any(outer(s,s,'+')%in%s)
Source Link
ConMan
  • 213
  • 1
  • 3

#R, 39 bytes

w<-function(s)!any(outer(s,s,'+')%in%s)

Call as w(s), where s is the set (actually vector) of values. Here's the output for some test cases:

> w(numeric(0)) # The empty set
[1] TRUE
> w(0)
[1] FALSE
> w(1)
[1] TRUE
> w(c(1, 5, 7))
[1] TRUE
> w(c(2, 4, 9, 13))
[1] FALSE

Where c() is the concatenation function that takes a bunch of values and makes it a vector.