### PROBLEM LINKS

### DIFFICULTY

EASY

### EXPLANATION

We want the lucky lucky number to be as small as possible. Thus, we want the number to have maximum number of 4’s placed in the beginning of the number. We can write N = 7Q + R, i.e, R = N mod 7.

If R = 0, count of 4 = 7Q and count of 7 = 0

If R = 1, count of 4 = 7*(Q-1) and count of 7 = 8 ( Thus we are removing some 4’s and placing some 7’s instead. We are trying to remove only the minumum required number of 4’s )

If R = 2, count of 4 = 7*(Q-2) and count of 7 = 16

If R = 3, count of 4 = 7*(Q-3) and count of 7 = 24

If R = 4, count of 4 = 7Q and count of 7 = 4

If R = 5, count of 4 = 7*(Q-1) and count of 7 = 12

If R = 6, count of 4 = 7*(Q-2) and count of 7 = 20

Whenever, count of 4 becomes negative, in any of the above cases, it is impossible to form a lucky lucky number.

### SETTER’S SOLUTION

Can be found here.

### TESTER’S SOLUTION

Can be found here.