Mathematica, 42 bytes
0!=##&@@d&&##&@@((d=IntegerDigits@#)∣#)&
I think 0!=##&@@d&&##&@@
is a new low in readability for Mathematica...
Explanation
Some of the basic syntactic sugar used here:
&
has very low precedence and turns everything left of it into an unnamed function.
&&
is just the And
operator.
#
is the argument of the nearest enclosing unnamed function.
##
is a sequence of all of the function's arguments.
@
is prefix notation for function calls, i.e. f@x == f[x]
.
@@
is Apply
, which passes the elements of a list as individual arguments to a function, i.e. f@@{a,b,c} == f[a,b,c]
.
With that out of the way...
(d=IntegerDigits@#)
This should be fairly self-explanatory: this gives us a list of the input's decimal digits and stores the result in d
.
(...∣#)
This tests the input for divisibility by each of its digits (because the divisibility operator is Listable
). This gives us a list of True
s and False
s.
...&@@...
We apply the function on the left-hand side to the list of booleans, such that each boolean is a separate argument.
...&@@d
We apply another function to d
, so that the individual digits are given as separate arguments. The function is 0!=##&
, i.e. Unequal[0, d1, d2, ...]
. It checks that all the digits are distinct (and that they are distinct from 0
but that's given by the challenge, and if it wasn't, it wouldn't be a divisor anyway). 0!=##&
is really just a 1-byte saver on using Unequal
itself, and it works because there's a 1-byte element (0
) that we know is not present. So this first thing checks that the digits are unique. Let's call this result U
...&&##
Again, this is really just shorthand for And[U, ##]
. With ##
being a sequences, the individual booleans from the initial divisibility check are expanded into the And
, so we get And[U, d1∣n, d2∣n, ...]
which checks that both the digits are unique and each digit divides the input.
1Related. (Asks for all the numbers instead of posing a decision problem.) – Martin Ender – 2017-07-04T11:54:10.197
2Can I take input as a string? – TheLethalCoder – 2017-07-04T12:38:48.730
2@TheLethalCoder Of course you can, that's a silly question. – Okx – 2017-07-04T12:40:37.277
10@Okx Not all challenge posters are as flexible in their allowed inputs as you so always worth an ask. – TheLethalCoder – 2017-07-04T12:41:47.677