Numbers with odd digits#8640

Numbers with odd digits (Editorial)

Written By : MathModel

Notice that (i.e. the integers will be only 4 digits) thus we can make a function that checks digit by digit if it's odd and if total count is 4 then it's one integer that we want and we print it.

Complexity \mathcal{O}(b-a).

from math import *

def check(n):
    cnt=0
    for i in str(n):
        if(int(i)&1):
            cnt+=1
    return cnt==4

a,b=map(int,input().split())
for i in range(a,b+1):
    if(check(i)):
        print(i,end=' ')