Skip to main content

Posts

Featured

Dining table problem

Dining table problem codevita  input format: tables  people 2      ,5 output : minimize the difference: like : 3,2 or 2,3 will leads to ncr same (5c3) * (2c2) = 10 * 1               = 10       pseudo code           step 1: find the people in equal tables step 2: find the ncr       : ncr1* n-r1c r2 ans so on... Code:(Python) import math as m table=2 # table count people=5 # number of people pairs=[people%table]*table #finding pairs while(sum(pairs)!=people):     for i in range(0,len(pairs)):         if sum(pairs)!= people:             pairs[i]+=1         else:             break counter=0 sumi=1 #findng ncr of pairs for i in range(0,len(pairs)):     if people!=pairs[i]:         counter=m.factorial(people)//m.factorial(pairs[i])   ...

Latest Posts