# GOODSET - Editorial

Author: Praveen Dhinwa
Tester: Prateek Gupta
Editorialist: Oleksandr Kulkov

CAKEWALK

None

### PROBLEM:

Output any set of distinct integers from 1 to 500 such that there are no three elements s_1+s_2=s_3.

### EXPLANATION:

Since n is up to 100, one can just output integers from 500-n to 499. Sum of any two such integers is greater than 500 so requirements will be satisfied.

One other solution is to output the first n odd integers, i.e. 1, 3, 5, 7 and so on. Sum of any two odd numbers is even, which wonâ€™t be present in this set.

### AUTHORâ€™S AND TESTERâ€™S SOLUTIONS:

Authorâ€™s solution will be updated soon.
Testerâ€™s solution will be updated soon.
Editorialistâ€™s solution can be found here.

3 Likes

import random
def summ(l,n,a):
flag=0
if(a not in l):
for j in range(len(l)):
for k in range(len(l)):
if(l[j]+l[k]==a and j!=k):
flag=1
break
if(flag==0):
l.append(a)
return(l)
for i in range(int(input())):
n=int(input())
l=[]
while(len(l)!=n):
a=random.randint(1,500)
summ(l,n,a)
print(*l)
#whatâ€™s wrong in this code?