We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
# ThinhNguyen97"""IMissThoseMomentsISpentWithYouKitchenTableMirrorSofa"""# Python is scripting language use interpreter# import numpy as np# import matplotlib.pyplot as plt# import pandas as pdfrommathimport*frombuiltinsimportstaticmethodfromcollectionsimportCounterfromcollectionsimportdefaultdictfromcollectionsimportnamedtuplefromcollectionsimportdequefromqueueimportLifoQueueimportheapqimportfunctoolsimporthashlibfromdatetimeimportdatetime,timedeltaimportjsonimportrefromitertoolsimport*importqueuefrombisectimportbisect_leftdefsolve(p,q):kaprekar_list=[]fornuminrange(p,q+1):square=num**2square_str=str(square)length=len(str(num))right_part=square_str[-length:]left_part=square_str[:-length]ifsquare_str[:-length]else'0'ifint(left_part)+int(right_part)==num:kaprekar_list.append(num)ifkaprekar_list:print(*kaprekar_list)else:print("INVALID RANGE")defmain():p=int(input())q=int(input())solve(p,q)if__name__=='__main__':main()
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Modified Kaprekar Numbers
You are viewing a single comment's thread. Return to all comments →