排列與組合概念複習\;(2)不盡相異物的排列

捷徑問題\
棋盤形街道如下圖所示，\;自A到B走捷徑，\;試求方法數。

A

B

階梯問題

一樓至二樓之間有7級樓梯，\;某人上樓每次跨1級或2級， \;試求方法數。

假設1級走x次，\;2級走y次，\;其中x,y為非負整數

⇒x+2y=7

Forward

順序問題

A、\;B、\;C...等七人排成一列，\;試求下列方法數：\ 
(1) \;A在B之前；\;(2)\; A在B之前， 且B在C之前；\;(3)\; A在B與C之前。

⇒\frac{7!}{2!}=2520

max = 37
s = 0 (slider from 0 to max, step 1)
l = 5 (slider from 2 to 5, step 1)
m = 4 (slider from 2 to 5, step 1)
n = 5 (slider from 2 to 5, step 1)
A: Corner[4] + (0.5, (-2.5))
text2: "\frac{" + (LaTeX[l + m + n]) + "!}{" + (LaTeX[l]) + "!×" + (LaTeX[m]) + "!×" + (LaTeX[n]) + "!}=" + (LaTeX[(l + m + n)! / (((l! * m!) * n!))]) + ""
B: A + (2, (-5))
list1 = Sequence(Segment[B + (k, 0), B + (k, (-m))], k, 0, l)
list2 = Sequence(Segment[B + (0, (-k)), B + (l, (-k))], k, 0, m)
text4: "由A到B走捷徑，\;共有" + (LaTeX[l]) + "個→與" + (LaTeX[m]) + "個↑"
text5: "故共有\;\frac{" + (LaTeX[l + m]) + "!}{" + (LaTeX[l]) + "!×" + (LaTeX[m]) + "!}=" + (LaTeX[(l + m)! / ((l! * m!))]) + "\;種方法"
text10: "x\;\;\;1" + (LaTeX[If[s ≥ 11, "\;\;\;3"]]) + "" + (LaTeX[If[s ≥ 12, "\;\;\;5"]]) + "" + (LaTeX[If[s ≥ 13, "\;\;\;7"]]) + "\\
y\;\;\;3" + (LaTeX[If[s ≥ 11, "\;\;\;2"]]) + "" + (LaTeX[If[s ≥ 12, "\;\;\;1"]]) + "" + (LaTeX[If[s ≥ 13, "\;\;\;0"]]) + ""
C: A + (1, (-8))
b_0 = Segment(C + ((-0.3), 0), If[s ≟ 10, C + (3.7, 0), If[s ≟ 11, C + (5.6, 0), If[s ≟ 12, C + (7.6, 0), If[s ≥ 13, C + (9.6, 0)]]]])
a_6 = Segment(C + (9.6, 0), C + (9.6, (-3.2)))
a_5 = Segment(C + (7.6, 0), C + (7.6, (-3.2)))
a_1 = Segment(C - (0.3, 0), C - (0.3, 3.2))
a_2 = Segment(C + (1.8, 0), C + (1.8, (-3.2)))
a_3 = Segment(C + (3.7, 0), C + (3.7, (-3.2)))
a_4 = Segment(C + (5.6, 0), C + (5.6, (-3.2)))
b_1 = Segment(C + ((-0.3), (-3.2)), If[s ≟ 10, C + (3.7, (-3.2)), If[s ≟ 11, C + (5.6, (-3.2)), If[s ≟ 12, C + (7.6, (-3.2)), If[s ≥ 13, C + (9.6, (-3.2))]]]])
b_2 = Segment(C + ((-0.3), (-1.6)), If[s ≟ 10, C + (3.7, (-1.6)), If[s ≟ 11, C + (5.6, (-1.6)), If[s ≟ 12, C + (7.6, (-1.6)), If[s ≥ 13, C + (9.6, (-1.6))]]]])
text14: "⇒\frac{4!}{3!×1!}" + (LaTeX[If[s ≥ 15, "+\frac{5!}{3!×2!}"]]) + "" + (LaTeX[If[s ≥ 16, "+\frac{6!}{5!×1!}"]]) + "" + (LaTeX[If[s ≥ 17, "+\frac{7!}{7!}"]]) + "\\" + (LaTeX[If[s ≥ 18, "\;\;=4+10+6+1"]]) + "
\\" + (LaTeX[If[s ≥ 19, "\;\;=21"]]) + ""
text1: "基本問題
\\將" + (LaTeX[l]) + "個籃球，\;" + (LaTeX[m]) + "個排球與" + (LaTeX[n]) + "個汽球排成一列，\;求方法數。"
text22: "\fgcolor{yellow}{(1)}\;分析：\\" + (LaTeX[If[s ≥ 23, "\;\;\;\;\;\;考慮下列兩種排法："]]) + "\\"
text24: "CDE\fgcolor{yellow}{A}FG\fgcolor{yellow}{B}\\
CDE\fgcolor{yellow}{B}FG\fgcolor{yellow}{A}\\" + (LaTeX[If[s ≥ 25, "在相對位置固定時，有一個A在B之前，\;就有一個B在A之前"]]) + ""
text30: "每6個相對位置只有1個正確\\
\fgcolor{yellow}{" + (LaTeX[If[s ≥ 31, "\frac{7!}{3!}"]]) + "" + (LaTeX[If[s ≥ 32, "=840"]]) + "}"
text27: "\fgcolor{yellow}{" + (LaTeX[If[(s ≥ 27) ∧ (s ≤ 32), "(2)", "(3)"]]) + "}\;分析：\\\;\;\;\;\;\;" + (LaTeX[If[s ≥ 28, "考慮下列相關位置"]]) + "\\" + (LaTeX[If[s ≥ 29, " \;\;\;\;\;\;\fgcolor{yellow}{A}DE\fgcolor{yellow}{B}G\fgcolor{yellow}{C}F"]]) + "\\" + (LaTeX[If[s ≥ 29, " \;\;\;\;\;\;\fgcolor{yellow}{A}DE\fgcolor{yellow}{C}G\fgcolor{yellow}{B}F"]]) + "\\" + (LaTeX[If[s ≥ 29, " \;\;\;\;\;\;\fgcolor{yellow}{B}DE\fgcolor{yellow}{A}G\fgcolor{yellow}{C}F"]]) + "\\" + (LaTeX[If[s ≥ 29, " \;\;\;\;\;\;\fgcolor{yellow}{B}DE\fgcolor{yellow}{C}G\fgcolor{yellow}{A}F"]]) + "\\" + (LaTeX[If[s ≥ 29, " \;\;\;\;\;\;\fgcolor{yellow}{C}DE\fgcolor{yellow}{A}G\fgcolor{yellow}{B}F"]]) + "\\" + (LaTeX[If[s ≥ 29, " \;\;\;\;\;\;\fgcolor{yellow}{C}DE\fgcolor{yellow}{B}G\fgcolor{yellow}{A}F"]]) + "\\"
text34: "在相對位置固定時：\;
\\" + (LaTeX[If[s ≥ 35, "\frac{7!}{3!}×2!"]]) + "" + (LaTeX[If[s ≥ 36, "=\frac{7!}{3}"]]) + "" + (LaTeX[If[s ≟ 37, "=1680"]]) + ""