mthree | Online Assessment | Lucky Number
Anonymous User
20289

Hello, here is the question:

A lucky number is a 10-based number, which has at least a "6" or an "8" in its digits. However, if it has "6" and "8" at the same time, then the number is NOT lucky. For example, "16", "38", "666" are lucky numbers, while "234" , "687" are not.

Now we want to know how many lucky numbers (without leading zeroes) are there between L and R, inclusive?

Constraints: 1≤L≤R≤10^18

Input (two integers L and R) : 1 10

Output: 2 (the numbers 6 and 8. Its a lame example, but its the one they gave).

The online assessment was here: https://www.codingame.com/training/expert/the-lucky-number
You can run and test your own code. You can't view the solutions unless you solve the problem.

P.S.
I tried a nested loop solution where the first loop would go through the range given and the second loop would go through the digits. This solution does not solve all of the test cases though.

Comments (9)