# Hackerrank Modified Kaprekar Numbers Solution

This is the solution to the Modified Kaprekar Numbers found in the implementation section of the algorithm domain in Hackerrank. A modified Kaprekar number is a positive whole number n with d digits, such that when we split its square into two pieces – a right hand piece r with d digits and a left hand piece l that contains the remaining d or dâˆ’1 digits, the sum of the pieces is equal to the original number (i.e. l + r = n).

Screenshot

The Code

`def sendKap(x,s): y=x*x y=str(y) s1=y[:len(y)/2:] s2=y[len(y)/2::] s3=int(s1)+int(s2) if(s3==x):  s.append(str(x))st=input()en=input()s=[]for i in range(st,en+1): if(i>9):  sendKap(i,s) elif(i==1):  s.append(str(i)) elif(i==9):  s.append(str(i))if(len(s)==0): print 'INVALID RANGE'else: print ' '.join(s)`

Got any problems feel free to comment them here !

Catch Me On

### Bikash Panda

Blogger / Embedded System Developer at WeArGenius
A techie, tinkerer and tech lover, who loves to blog and feels everyone can learn tech provided they have the right attitude towards learning and passion. By profession, I am an IOT developer working in Smart Home/ Smart Grid domain.
Catch Me On

#### Bikash Panda

A techie, tinkerer and tech lover, who loves to blog and feels everyone can learn tech provided they have the right attitude towards learning and passion. By profession, I am an IOT developer working in Smart Home/ Smart Grid domain.