You are viewing a single comment's thread. Return to all comments →
Here is my python code (simple brute force):
def kaprekarNumbers(p, q): arr = [] for i in range(p, q + 1): curr = str(i ** 2) d1 = curr[:len(curr) // 2] if len(curr) > 1 else "0" d2 = curr[len(curr) // 2:] if len(curr) > 1 else curr if int(d1) + int(d2) == i: arr.append(str(i)) print(" ".join(arr) if arr != [] else "INVALID RANGE")
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Modified Kaprekar Numbers
You are viewing a single comment's thread. Return to all comments →
Here is my python code (simple brute force):