-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
40 lines (38 loc) · 973 Bytes
/
test.py
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
32
33
34
35
36
37
38
39
40
import numpy as np
class Solution:
def inverse_num(self, nums):
if nums >999999999999:
return 0
elif nums ==0:
return 0
else:
if nums>0:
flag= True
else:
flag = False
nums *= -1
num_list = list(str(nums))
# print(num_list)
while num_list[-1] == '0':
num_list.pop()
tmp = "".join(num_list[::-1])
# if flag:
# print(tmp)
# else:
# print('' + tmp)
# print(tmp)
return tmp
def ans(self, n):
ans = []
count = 0
for i in range(10, n):
temp = self.inverse_num(i)
temp2 = i * 4
if temp2 == int(temp):
count += 1
ans.append((int(i), int(temp)))
ans = np.array(ans)
print(count)
print(ans)
return count, ans
Solution().ans(10000)