#Prolog 117 bytes

`b(X):-between(0,9,X).
w(X):-write(X).
y():-b(A),b(B),b(C),b(D),X is A+B+C+D,X=9,(A=0;B=0;C=0;D=0),w(A),w(B),w(C),w(D).`