Problem:


Score : 300 points

Problem Statement

You are given an integer N. Among the integers between 1 and N (inclusive), how many Shichi-Go-San numbers (literally "Seven-Five-Three numbers") are there?

Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:

When the number is written in base ten, each of the digits 7, 5 and 3 appears at least once, and the other digits never appear.

Constraints

1 \leq N < 10^9

N is an integer.

Input

Input is given from Standard Input in the following format:

N

Output

Print the number of the Shichi-Go-San numbers between 1 and N (inclusive).

Sample Input 1

575

Sample Output 1

4

There are four Shichi-Go-San numbers not greater than 575: 357, 375, 537 and 573.

Sample Input 2

3600

Sample Output 2

13

There are 13 Shichi-Go-San numbers not greater than 3600: the above four numbers, 735, 753, 3357, 3375, 3537, 3557, 3573, 3575 and 3577.

Sample Input 3

999999999

Sample Output 3

26484



Sample input:
575


Sample output:
4

Submission status: Wrong Answer

Solution code:
inn = int(input())

result = 0

if inn < 357:
    print(0)

elif inn < 99999999:
    for i in range(357, inn, 2):

        str_i = str(i)

        num_3 = 0
        num_5 = 0
        num_7 = 0

        # check_357 = [i in ['3','5','7'] for i in str(i)]
        # if sum(check_357) == len(str_i):

        # if '3' in str_i and '5' in str_i and '7' in str_i:
            # if re.sub(r'3|5|7', '', str_i) == '':

        for j in str_i:
            if num_3 == 0 and j == '3':
                num_3 = 1

            elif num_5 == 0 and j == '5':
                num_5 = 1

            elif num_7 == 0 and j == '7':
                num_7 = 1

            elif j in ['0', '1', '2', '4', '6', '8', '9']:
                num_3 = 0
                break

            # if '0' not in str_i and '1' not in str_i and '2' not in str_i and '4' not in str_i and '6' not in str_i and '8' not in str_i and '9' not in str_i:

        if num_3 == 1 and num_5 == 1 and num_7 == 1:
                result += 1

    print(result)

else:
    result = 8334
    if inn >= 333333357 and inn <= 377777776:
        for i in range(333333357, inn if inn <= 377777776 else 377777776, 2):

            str_i = str(i)

            if '3' in str_i and '5' in str_i and '7' in str_i:
                if '0' not in str_i and '1' not in str_i and '2' not in str_i and '4' not in str_i and '6' not in str_i and '8' not in str_i and '9' not in str_i:

                    result += 1

    if inn >= 533333337 and inn <= 577777774:
        result = 14384
        for i in range(533333337, inn if inn <= 577777774 else 577777774, 2):

            str_i = str(i)

            if '3' in str_i and '5' in str_i and '7' in str_i:
                if '0' not in str_i and '1' not in str_i and '2' not in str_i and '4' not in str_i and '6' not in str_i and '8' not in str_i and '9' not in str_i:

                    result += 1

    if inn >= 733333335 and inn <= 777777754:
        result = 20434
        for i in range(733333335, inn if inn <= 777777754 else 777777754, 2):

            str_i = str(i)

            if '3' in str_i and '5' in str_i and '7' in str_i:
                if '0' not in str_i and '1' not in str_i and '2' not in str_i and '4' not in str_i and '6' not in str_i and '8' not in str_i and '9' not in str_i:

                    result += 1

    print(result)

Submission status: Wrong Answer

Solution code:
N = int(input())

def make753(X):
    add_ary = []
    for i in X:
        add_ary.append(int("3" + str(i)))
        add_ary.append(int("5" + str(i)))
        add_ary.append(int("7" + str(i)))
    return add_ary

L = []
L.append([3, 5, 7])
for i in range(10):
    L.append(make753(L[i]))

def flatten(nested_list):
    """2重のリストをフラットにする関数"""
    return [e for inner_list in nested_list for e in inner_list]

S = flatten(L)

true = []
for k in S:
    check = set(list(str(k)))
    if check == {'3', '5', '7'}:
        true.append(k)

true.sort()

z = 0
count = 0
while true[z] < N:
    count += 1
    z += 1

print(count)

Submission status: Wrong Answer

Solution code:
s = input()
n = 1000
for i in range(0, len(s)-3):
    b = int(s[i:i + 3])
    c = 753 - b
    if c < 0:
        c = c * (-1)
    if n > c:
        n = c
print(n)