given that it is 2-4-2-1 code.
properties of 2-4-2-1 code is self complementary, means if you fix a representation for digit x then you have fixed the representation for 9's complement of x...
if you put 0010 for representing 2 then 7 must be represented as 1101 ( which is complement to 2 ) but not as 0111.
therefore you have to fix the representation of digits before representing the number...