blob: 4b3831a16c5aba243b55026bed8c83734b81bc10 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#!/usr/bin/python
import sys
def is_simple_number(n):
# Determine if the number is simple
seen = {}
for i in str(n):
if i in seen:
# We've seen the digit before. It's not simple
return False
seen[i] = 1
# It is simple
return True
def main(n):
# Iterate through the list counting the number of simple numbers
simple_count = 0
for i in range(1, n+1):
if is_simple_number(i):
simple_count += 1
# Print the result
print(simple_count)
if __name__ == '__main__':
main(int(sys.argv[1]))
|