PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
def sumofsq(a):
b,ss=[],[]
sq=[x*x for x in range(1,int(a**0.5+1))]
for s in sq[::-1]:
temp=a-s
b.append((sq.index(s)+1))
while temp>0:
c=int(temp**0.5)
b.append(c)
temp=temp-(c*c)
ss.append(sorted(b))
b=[]
return([list(item) for item in set(tuple(row) for row in ss)])
a=int(input())
sos=sumofsq(a)
losos=[len(x) for x in sos]
for row in sos:
if len(row)== min(losos):
print(a,end=' = ')
print(*row[::-1],sep=chr(253)+'+',end=chr(253)+'\n')
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run