Let $a$, $b$, $c$, and $d$ four integers such that $0 <a <b <c <d$. We can get all integers from $1$ to $40$ by expressions containing or not only the numbers $a, b, c$ and $d$. In these expressions $a, b, c$ and $d$ do not appear more than once and in those expressions that use more than one of these numbers only addition and / or subtraction are allowed. Determine $a, b, c$ and $d$.
I have found out these numbers but not in an elegant way. I wonder if anyone knows any more appropriate method to tackle that problem.
Edit: It's not sufficiently clear to me why {1,3, 9, 27} is the only set that solves the problem. If it was stated in the problem "get all integers from 1 to 38", then there would be at least three solutions for this problem: {1, 3, 9, 25}, {1, 3, 9, 26} and {1, 3 , 9, 27}.