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.
defgetNextConsideredInt(a,sup):"""Fonctionusedtogetthenextconsideredintthankstothevectora.Theparametersupisthemaxofvectorb.Thisalgorithmtakesallintbetween1andthesup+1:->foreach"value"itverifiesifitisafactorofallnumbersofthevectora.Ifthisconditionisverified,yieldthe"value"->Insteadofstartingfrom1,itdirectlystatsfromthemaxofa."""firstval=max(a)forvalueinrange(firstval,sup+1):# For else condition : Really important hereforelementina:ifvalue%element:breakelse:yieldvaluedefvectorDiviseInt(vector,intElement):"""Foreachelementinthevectorb,ifelement%consideredInt!=0,returnfalse"""foreinvector:ife%intElement:return0return1defgetTotalX(a,b):nb_vals=0forconsIntingetNextConsideredInt(a,max(b)):nb_vals+=vectorDiviseInt(b,consInt)returnnb_vals
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Between Two Sets
You are viewing a single comment's thread. Return to all comments →
Here is my python code