#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)