From: David C. Ullrich on 24 May 2010 09:02 On Sun, 23 May 2010 10:11:59 -0700 (PDT), amzoti <amzoti(a)gmail.com> wrote: >On May 23, 6:58�am, David C. Ullrich <ullr...(a)math.okstate.edu> wrote: >> On Sun, 23 May 2010 05:34:51 -0700 (PDT), amarj japp >> >> >> >> <amarj.ro...(a)gmail.com> wrote: >> >Q. How many 6 digit number without repetition of digits are there such >> >that the >> > � � digits are all non-zero and 1 and 2 do not appear consecutively >> >in either order. >> >> >Soln: The Book considers for cases >> > � � � � (i) � Neither 1 nor 2 appears as digits : �(P 7 6) = 7! >> > � � � � (ii) �1, but not 2 appears as a digit �: 6 (P 7 5) >> > � � � �(iii) �2, but not 1 appears � � � � � � � �: 6 (P 7 5) >> > � � � �(iv) Both 1 and 2 appears � � � � � � �: 2.7.4.P(6,3) + >> >4.7.6.3.P(5,2) >> >> >We add them to get the total of 52080 >> >> >My question is , if i tries to do this using indirect counting i.e >> >Number of ways , when the 1 and 2 appears together is 2*P(8,6) >> >If is subtract above from P(9 6) i.e P(9,6) - 2*P(8,6) = 20160 >> >> >I don't understand how i am not getting same answer , please suggest >> >what i am doing wrong. >> >> Why do you think that the number of permutations where a 1 and a 2 >> appear together is 2*P(8,6)? >> >> I verified the answer using brute-force calculation. >> Extremely bad, maximally inefficient Python that >> does the job: >> >> def bad(x,y): >> � return (x,y) == (0,1) or (x,y) == (1,0) >> >> def ok(s): >> � for j in range(5): >> � �if bad(s[j],s[j+1]): return 0 >> � return 1 >> >> ss = [()] >> for places in range(6): >> � ss = [s+(j,) for s in ss for j in range(9) if not j in s] >> >> count = 0 >> for s in ss: >> � if ok(s): >> � � count = count + 1 >> >> print count #5280 >> >> >Thanks >> >> > >Did you miss a zero or something is amiss? (52080) That was a typo on my part - it actually returns 52080.
First
|
Prev
|
Pages: 1 2 Prev: A question on Farey's sequences. Next: THE HOLY GRAIL ~ CANTOR DISPROOF |