Created
July 31, 2014 05:56
-
-
Save rohit-jamuar/e2f0709446ef035b464a to your computer and use it in GitHub Desktop.
Count of numbers (in range [1,input_num]) which don't have 'exclude'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
def number_counting(input_num, exclude): | |
''' | |
Returns the count of numbers (in range [1,input_num]) which don't | |
have 'exclude' among their constituent digits. | |
''' | |
if type(input_num) == int and type(exclude) == int: | |
exclude = str(exclude) | |
if len(exclude) == 1: | |
count = 0 | |
for number in range(1, input_num+1): | |
temp = str(number) | |
if exclude not in temp: | |
count += 1 | |
return count | |
else: | |
return "Argument 'exclude' should be a digit!" | |
else: | |
return "Argument 'input_num' and/or 'exclude' should be an integer!" | |
if __name__ == '__main__': | |
print number_counting(1000, 7) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment