Skip to content

Instantly share code, notes, and snippets.

@danibrear
Created October 4, 2013 01:27
Show Gist options
  • Save danibrear/6819674 to your computer and use it in GitHub Desktop.
Save danibrear/6819674 to your computer and use it in GitHub Desktop.
python program to figure out how many numbers there are between 1-x with repeating digits.
def get_digits(num):
rem = num % 10
it_num = num/10
digits = []
while(rem > 0 or it_num > 0):
if rem in digits: return None
digits.insert(0, rem)
rem = it_num % 10
it_num = it_num/10
return num
if __name__ == '__main__':
num = 1000
digits = []
for x in range(1,num+1):
solution = get_digits(x)
if solution:
digits.append(solution)
print len(digits)
print num - len(digits)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment