diff options
| author | Omar Magdy <omar.professional8777@gmail.com> | 2022-04-30 01:13:40 +0200 |
|---|---|---|
| committer | Omar Magdy <omar.professional8777@gmail.com> | 2022-04-30 01:13:40 +0200 |
| commit | a0d7b8320a8996eee0ed957b79c3a882f8b47146 (patch) | |
| tree | 76242ae2b19bad00796ed6d0104da8a0e4a99abe /python | |
| download | competitive-programming-a0d7b8320a8996eee0ed957b79c3a882f8b47146.tar.xz competitive-programming-a0d7b8320a8996eee0ed957b79c3a882f8b47146.zip | |
Added all current problems
Diffstat (limited to 'python')
| -rwxr-xr-x | python/FindDigits.py | 21 | ||||
| -rwxr-xr-x | python/Kaprekar.py | 20 |
2 files changed, 41 insertions, 0 deletions
diff --git a/python/FindDigits.py b/python/FindDigits.py new file mode 100755 index 0000000..6bdfebf --- /dev/null +++ b/python/FindDigits.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 + + +def find_digit(n): + count = 0 + list = [int(i) for i in n] + for i in range(len(n)): + if list[i] == 0: + continue + if int(n) % list[i] == 0: + count = count + 1 + return count + +t = int(input()) + +while(t): + t = t - 1; + n = input() + print(find_digit(n)) + + diff --git a/python/Kaprekar.py b/python/Kaprekar.py new file mode 100755 index 0000000..199b1c2 --- /dev/null +++ b/python/Kaprekar.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 +from math import ceil + +p = int(input()) +q = int(input()) + +def splitNum(n): + sn = str(n) + l = len(sn) + d = int((l + 1) / 2) + if l % 2 == 0: + d = int(ceil(l / 2)) + if(len(sn[d:].lstrip('0')) != 0): + return int(sn[0:l - d]) + int(sn[l-d:].lstrip('0')) + +for i in range(p, q): + if i == splitNum(i * i): + print(i) + + |
