will you join with me ?
Need a team, python prefered.
Also it would be good if we become programming buddies/rivals so that we can participate in more contests that require such team pairing.
Considerer to jump inside this sub reddit there is a pull and a live chat https://www.reddit.com/r/ContestProgramming/
Hello, I am facing some LOGICAL problem while solving PRACTICE ROUND QUESTION FOR HASH CODE 2021ā¦
I am trying to create a score list by comparing multiple pizzas simultaneoulyā¦as a result my compilation time went over 1 hour 30 minutes ā¦
PLEASE HELP TO IMPROVE MY LOGIC
OR
SUGGEST SOME OTHER METHOD TO SOLVE THAT PROBLEM
Oh, Iām not able to see any code, maybe you need to post your code and your idea well-formed.
I think that also Reddit is a good place where post code and make a good discussion, a new community is here
P.S: Donāt use the uppercase when you are asking for help, in some countries it is not a good manners. Thanks
in1=input()
totalpizza=0
in1_list=in1.split() #len=4
all_pizza=[] #store every data of all pizzas
#iterating no. of pizzas tim
for i in range(1,int(in1_list[0])+1):
#creating list for storing datas of each pizza [no of ingredients in integer , ingredients separeted by commas]
pizza=input()
pizza_list=pizza.split()
#appending pizza in all_pizza
all_pizza.append(pizza_list)
#---------------- complete pizza list created successfully -----------------------------
āāā
NOW CREATING TEAM LIST , TO WHOM WE HAVE TO DELIVER PIZZAā¦
#dictionary for sum and corrosponding values of team required
team={}
for a in range(0,int(in1_list[1])):
for b in range(0,int(in1_list[2])):
for c in range(0,int(in1_list[3])):
team[(a2) + (b3) +(c*4)]= [a,b,c]
#NOW calculating max value of KEY smaller or equal than no of pizzas
keys=team.keys()
job=ānoā
while job==ānoā:
max_key=max(keys)
if max_key>int(in1_list[0]):
del team[max_key]
else:
job=ādoneā
#------------TILL HERE WE GOT NO OF TEAMS FOR DELIVERY --------------------
āāā
CODING TO GENERATE OUTPUTā¦
#creating dictionary for storing SCORES OF 2 MEMBERS TEAM
copy=all_pizza.copy()
team2=[]
team4=[]
count=0
if totalpizza<int(in1_list[0]) and (count<int(in1_list[3])) :
score_list_4=[]
for z in range(0,len(all_pizza)):
ingre=int(all_pizza[z][0])
#iterating ingre no of times
for f in range(0,len(all_pizza)):
for k in range(0,len(all_pizza)):
for p in range(0,len(all_pizza)):
#creating score
score=0
for v in range(1,ingre+1):
if all_pizza[z][v] in all_pizza[p]:
pass
else:
score+=1
if all_pizza[z][v] in all_pizza[k]:
score-=1
else:
score+=1
if all_pizza[z][v] in all_pizza[f]:
score-=2
else:
score+=1
inge=int(all_pizza[f][0])
for v in range(1,inge+1):
if all_pizza[f][v] in all_pizza[k]:
score-=1
else:
score+=1
if all_pizza[f][v] in all_pizza[p]:
score-=2
else:
score+=1
inge=int(all_pizza[k][0])
for v in range(1,inge+1):
if all_pizza[k][v] in all_pizza[p]:
score-=2
else:
score+=1
# appending scores with indexes of pizza used..
score_list_4.append([score,p,k,f,z])
#ā¢ā¢ā¢ā¢ā¢ā¢ā¢ā¢ā¢ā¢ā¢ā¢GENERATING FINALNOUTPUT FOR 2 MEMBERS TEAMā¢ā¢ā¢ā¢ā¢ā¢ā¢ā¢ā¢ā¢ā¢ā¢
count=0
kite_list=score_list_4.copy()
for th in kite_list:
keys_4=[]
for it in range(0,int(len(score_list_4))):
keys_4.append(score_list_4[it][0])
end=0
try:
max_k4= max(keys_4)
except:
end=1
print(len(score_list_2),score_list_2)
if max_k4== th[0] and (th in score_list_4) and end ==0:
r1=th[1]
r2=th[2]
r3=th[3]
r4=th[4]
if r1==r2:
for x in kite_list:
if x in score_list_4:
if x[1] != x[2]:
score_list_4.remove(th)
end=1
break
if r1==r3:
for x in kite_list:
if x in score_list_4:
if x[1] != x[3]:
score_list_4.remove(th)
end=1
break
if r3==r2:
for x in kite_list:
if x in score_list_4:
if x[3] != x[2]:
score_list_4.remove(th)
end=1
break
if r1==r4:
for x in kite_list:
if x in score_list_4:
if x[1] != x[4]:
score_list_4.remove(th)
end=1
break
if r2==r4:
for x in kite_list:
if x in score_list_4:
if x[2] != x[4]:
score_list_4.remove(th)
end=1
break
if r4==r3:
for x in kite_list:
if x in score_list_4:
if x[4] != x[3]:
score_list_4.remove(th)
end=1
break
if end ==0:
totalpizza+=4
if totalpizza<=int(in1_list[0]):
li=[]
for a in range(1,5):
val=all_pizza[th[a]]
ind=copy.index(val)
li.append(ind)
team2.append([4,li[0],li[1],li[2],li[3]])
team4.append([4,th[1],th[2],th[3],th[4]])
count+=1
else:
end=1
totalpizza-=4
if end==0:
for kite in kite_list:
if kite in score_list_4:
if r1==kite[1] or r1==kite[2] or r1==kite[3] or r1==kite[4]:
score_list_4.remove(kite)
elif r2==kite[2] or r2==kite[1] or r2==kite[3] or r2==kite[4]:
score_list_4.remove(kite)
elif r3==kite[2] or r3==kite[1] or r3==kite[3] or r3==kite[4] :
score_list_4.remove(kite)
elif r4==kite[2] or r4==kite[1] or r4==kite[3] or r4==kite[4] :
score_list_4.remove(kite)
else:
pass
if count>=int(in1_list[3]) or totalpizza>int(in1_list[0]):
break
#+++++ output for4 members team completed successfully+++++++
renovating all_pizzaā¦
dub=[]
if totalpizza<int(in1_list[0]):
for i in team2:
v=all_pizza[i[1]]
x=all_pizza[i[2]]
w=all_pizza[i[3]]
r=all_pizza[i[4]]
dub.append(v)
dub.append(x)
dub.append(w)
dub.append(r)
for a in dub:
all_pizza.remove(a)
starting 3 members outputā¦
team3=[]
count=0
if totalpizza<int(in1_list[0]) and (count<int(in1_list[2])):
score_list_3=[]
for z in range(0,len(all_pizza)):
ingre=int(all_pizza[z][0])
#iterating ingre no of times
for f in range(0,len(all_pizza)):
for k in range(0,len(all_pizza)):
#creating score
score=0
for v in range(1,ingre+1):
if all_pizza[z][v] in all_pizza[k]:
pass
else:
score+=1
if all_pizza[z][v] in all_pizza[f]:
score-=1
else:
score+=1
inge=int(all_pizza[f][0])
for v in range(1,inge+1):
if all_pizza[f][v] in all_pizza[k]:
score-=1
else:
score+=1
# appending scores with indexes of pizza used..
score_list_3.append([score,k,f,z])
#ā¢ā¢ā¢ā¢ā¢ā¢ā¢ā¢ā¢ā¢ā¢ā¢GENERATING FINALNOUTPUT FOR 2 MEMBERS TEAMā¢ā¢ā¢ā¢ā¢ā¢ā¢ā¢ā¢ā¢ā¢ā¢
kite_list=score_list_3.copy()
for th in kite_list:
keys_3=[]
for it in range(0,int(len(score_list_3))):
keys_3.append(score_list_3[it][0])
end=0
try:
max_k3= max(keys_3)
except:
end=1
print(len(score_list_2),score_list_2)
if max_k3 == th[0] and (th in score_list_3) and end ==0:
r1=th[1]
r2=th[2]
r3=th[3]
if r1==r2:
for x in kite_list:
if x in score_list_3:
if x[1] != x[2]:
score_list_3.remove(th)
end=1
break
if r1==r3:
for x in kite_list:
if x in score_list_3:
if x[1] != x[3]:
score_list_3.remove(th)
end=1
break
if r3==r2:
for x in kite_list:
if x in score_list_3:
if x[3] != x[2]:
score_list_3.remove(th)
end=1
break
if end ==0:
totalpizza+=3
if totalpizza<=int(in1_list[0]):
li=[]
for a in range(1,4):
val=all_pizza[th[a]]
ind=copy.index(val)
li.append(ind)
team2.append([3,li[0],li[1],li[2]])
team3.append([3,th[1],th[2],th[3]])
count+=1
else:
end=1
totalpizza-=3
if end==0:
for kite in kite_list:
if kite in score_list_3:
if r1==kite[1] or r1==kite[2] or r1==kite[3] :
score_list_3.remove(kite)
elif r2==kite[2] or r2==kite[1] or r2==kite[3] :
score_list_3.remove(kite)
elif r3==kite[2] or r3==kite[1] or r3==kite[3] :
score_list_3.remove(kite)
else:
pass
if count>=int(in1_list[2]) or totalpizza>int(in1_list[0]):
break
#++++++++++++ OUTPUT OF 3 MEMBERS TEAM SUCCESSFULLY COMPLETED++++
renovating all_pizzaā¦
dub=[]
if totalpizza<int(in1_list[0]):
for i in team3:
z=all_pizza[i[3]]
v=all_pizza[i[1]]
x=all_pizza[i[2]]
dub.append(v)
dub.append(x)
dub.append(z)
for a in dub:
all_pizza.remove(a)
starting output for 2members team
count=0
if count<int(in1_list[1]) and totalpizza<int(in1_list[0]):
score_list_2=[]
######value=team[max_key]
#printing 1st line output
####print(value[0]+value[1]+value[2])
#coding for measuring maximum score for 2 member teams
for z in range(0,len(all_pizza)):
ingre=int(all_pizza[z][0])
#iterating ingre no of times
for f in range(0,len(all_pizza)):
#creating score
score=0
for v in range(1,ingre+1):
if all_pizza[z][v] in all_pizza[f]:
pass
else:
score+=1
# appending scores with indexes of pizza used..
score_list_2.append([score,z,f])
#ā¢ā¢ā¢ā¢ā¢ā¢ā¢ā¢ā¢ā¢ā¢ā¢GENERATING FINALNOUTPUT FOR 2 MEMBERS TEAMā¢ā¢ā¢ā¢ā¢ā¢ā¢ā¢ā¢ā¢ā¢ā¢
kite_list=score_list_2.copy()
for th in kite_list:
keys_2=[]
for it in range(0,int(len(score_list_2))):
keys_2.append(score_list_2[it][0])
end=0
try:
max_k2= max(keys_2)
except:
end=1
print(len(score_list_2),score_list_2)
if max_k2 == th[0] and (th in score_list_2) and end ==0:
#NEW LOGIC //////
r1=th[1]
r2=th[2]
if r1==r2:
for x in kite_list:
if x in score_list_2:
if x[1] != x[2]:
score_list_2.remove(th)
end=1
break
if end ==0:
totalpizza+=2
if totalpizza<=int(in1_list[0]):
li=[]
for a in range(1,3):
val=all_pizza[th[a]]
ind=copy.index(val)
li.append(ind)
team2.append([2,li[0],li[1]])
count+=1
else:
end=1
totalpizza-=2
if end==0:
for kite in kite_list:
if kite in score_list_2:
if r1==kite[1] or r1==kite[2] :
score_list_2.remove(kite)
elif r2==kite[2] or r2==kite[1] :
score_list_2.remove(kite)
else:
pass
if count>=int(in1_list[1]) or totalpizza>int(in1_list[0]):
break
#+++++++++ completed 2 members output ++++++++++++++
print(len(team2))
for t in team2:
for k in t:
print(k,end=" ")
print()
file=open(āa_out_by_finalrenovated.txtā,āwā)
file.write(str(len(team2)))
for t in team2:
for k in t:
file.write(str(k))
#OUTPUT GENERATION COMPLETED
#______________ PROGRAM COMPLETED ___________________________________________
Hey , bro this is my code for practicr round
VERY TIME CONSUMINGā¦
help me pleaseā¦
Hiiā¦can anyone take inti a team. I am looking fr a team memberā¦I am a beginnerā¦so i want a beginner level tam memberā¦
Hey, I want to form a team, if you guys have space in the team. I am good with python, Java, and I know C++ also(a bit average).
Hey, Do you still need a member in your team ?
yes I do, please join if you can.
is your username T B? I guess you are already in, thatās why.
Yes.
hey,join me,i code in c language.
Java and C coders join here:
I want to join your team. Please give your invitation link to join your team
I have joined your team
Thank you