# A343780 - If n good guys followed by n bad guys stand in a circle, the least q such # that executing every q-th person gets all bad guys first. # Python program by Bert Dobbelaere def depth( ngood, nbad, position, qminus1): rv=0 while True: m=ngood+nbad r=(position+qminus1)%m if r < ngood: return rv rv+=1 ; nbad-=1 ; position=r def increaseWheelModulus(in_list, in_modulus, allowedresidues, inc_modulus): out_list=[] f=1 while (f*in_modulus)%inc_modulus != 0: f+=1 for k in range(f): for r in in_list: r0=k*in_modulus+r if allowedresidues[r0%inc_modulus]: out_list.append(r0) return out_list, in_modulus*f STOPLENGTH=10000000 # Stop growing our modulus and list of residues if this value is exceeded (performance/memory tradeoff) n=1 while True: lst,M = [0],1 nbad=1 while nbad<=n and len(lst)