% use [nosolutions] flag to hide solutions.
% use [solutions] flag to show solutions.
\documentclass[
	solutions
]{../../resources/ormc_handout}
\usepackage{../../resources/macros}



\newcommand{\nck}[2] {
	\ensuremath{
		{}_{#1}C_{#2}
	}
}

\newcommand{\npk}[2] {
	\ensuremath{
		{}_{#1}P_{#2}
	}
}

\uptitlel{Advanced 1}
\uptitler{ORMC Summer Sessions}
\title{Combinatorics}
\subtitle{Prepared by \githref{Mark} on \today}

\begin{document}

	\maketitle

	\section{Getting started}

	An \textbf{ordered} arrangement of objects is called a \textit{permutation}. \par
	An \textbf{unordered} selection of objects is called a \textit{combination}\footnotemark{}\hspace{-1ex}. \par
	All the following problems involve permutations.

	\footnotetext{A \say{combination lock} cares about the order of its digits, so its name is inaccurate. Such an object is actually a \textit{permutation} lock!}


	\problem{}<ABCDE>
	How many different ways are there to rearrange the letters ABCDE?

	\begin{solution}
		$5 \times 4 \times 3 \times 2 \times 1 = 120$
	\end{solution}

	\vfill

	\problem{}<AtoZ>
	How many different ways are there to arrange the letters ABCDEFG...XYZ? \par
	You don't need to fully evaluate your answer, it is a \textit{very} big number. \par
	\hint{Look at \ref{ABCDE} again, and try to create a general strategy.}


	\begin{instructornote}
		A hint for students that are stuck: \par
		In \ref{ABCDE}, start with five blank spaces. How many choices are there for A's position? \par
		Once A is placed, how many are left for B?
	\end{instructornote}

	\vfill
	\pagebreak

	\definition{}
	The \textit{factorial} of a positive integer $x$ is $x \times (x-1) \times ... \times 1$. We denote this $x!$. \par
	For example, $8! = 8 \times 7 \times 6 \times 5 \times 4 \times 3 \times 2 \times 1 = 40320$.

	\problem{}
	Compute $\frac{10!}{8!}$
	\vfill

	\problem{}
	Convince yourself that $(n+1)! = n! \times (n+1)$, and use this fact to show that $0! = 1$.
	\vfill

	\problem{}
	How many ways are there to choose three student council officers from a class of 20 students? \par
	How many ways are there to choose a president, a vice-president, and a treasurer from the same class? \par
	\hint{You answers should be different. In which case does order matter?}

	\begin{instructornote}
		Have your students consider the non-unique arrangements and count how many are redundant.
	\end{instructornote}

	\vfill
	\pagebreak

	\problem{}
	Say you have 4 red balls and 3 green balls. How many different ways can you arrange them on the table in font of you? \par

	\begin{solution}
		Consider the sequence RRRRGGG. There are $4!$ ways to rearrange the red balls, and $3!$ ways to rearrange the green balls. This is true for any sequence.

		So, our solution is $\frac{7!}{3!4!}$.
	\end{solution}

	\vfill

	\problem{}
	How many \textit{unique} anagrams can we create from the word CRESCENDO?


	\begin{solution}
		CRESCENDO = CC EE RSNDO, our solution is $\frac{9!}{2!2!} = 90720$
	\end{solution}
	\vfill

	\problem{}<3fromABCDE>
	Given the letters ABCDE, how many different three-letter words can we make without repeating letters?
	\vfill
	\pagebreak

	\section{Permutations}

	It would be convenient to have a general tool for counting permutations. Let us try to create one. \par
	(Remember, permutations are \textit{ordered} arrangements of objects.)

	First, let's create a function $\npk{n}{k}$, which tells us how many $k$-object permutations we can choose from a group of $n$ objects.

	\problem{}
	What is $\npk{5}{3}$? \par
	\hint{See \ref{3fromABCDE}}


	\vfill
	``Choosing $k$ items from $n$'' is a lot like splitting our $n$ objects into two groups: those we choose, and those we don't.

	\begin{center}
		\begin{tikzpicture}
			% Points
			\path [draw=black, fill=black] (0,0) circle (5pt);
			\path [draw=black, fill=black] (1,0) circle (5pt);
			\path [draw=black, fill=white] (2,0) circle (5pt);

			% "Choose these" bracket
			\draw[shift={(-0.5, -1)}, color=oblue, thick] (0pt,0pt) -- (0pt,3pt);
			\draw[color=oblue, thick] (-0.5, -1) -- (2.5, -1) node[below, midway] {Choose $k$ objects};
			\draw[shift={(2.5, -1)}, color=oblue, thick] (0pt,0pt) -- (0pt,3pt);


			\draw[-] (3, -0.5) -- (3, 0.5);

			\path [draw=black, fill=white] (4,0) circle (5pt);
			\path [draw=black, fill=black] (5,0) circle (5pt);

			% "Leave these" bracket
			\draw[shift={(3.5, -1)}, color=oblue, thick] (0pt,0pt) -- (0pt,3pt);
			\draw[color=oblue, thick] (3.5, -1) -- (5.5, -1) node[below, midway] {Leave the rest};
			\draw[shift={(5.5, -1)}, color=oblue, thick] (0pt,0pt) -- (0pt,3pt);
		\end{tikzpicture}
	\end{center}

	If we rearrange these, we get different permutations. How can we count them?

	\problem{}<nPk>
	Using the above diagram, create a formula for $\npk{n}{k}$. \par
	\hint{We're counting \textit{permutations}, so the order of items in the first group matters.}

	\begin{solution}
		$\npk{n}{k}= \frac{n!}{(n-k)!}$

		There are $n!$ possible arrangements of $n$ objects. However, since the order of the elements not chosen does not matter, we'll end up with $(n-k)!$ redundant orderings of each.
	\end{solution}


	\vfill
	\pagebreak

	\section{Combinations}

	Now, let's count \textit{combinations}. \par
	Here, we only care about \textit{which} items we choose---not the order in which we choose them.
	We'll make a function $\nck{n}{k}$ (\say{n choose k}), which will tell us
	how many different ways we can choose $k$ items from a set of $n$.

	\problem{}
	Find an expression for $\nck{n}{k}$ by modifying your definition of $\npk{n}{k}$.


	\vfill

	Usually, $\nck{n}{k}$ is written as $\binom{n}{k}$. This is also called the \textit{binomial coefficient}.


	\problem{}<manyballs>
	Say you have a few coins on the table in font of you:
	\begin{itemize}
		\item 8 identical 1-kopek\footnotemark{} coins
		\item 3 identical 2-kopek coins
		\item 6 identical 5-kopek coins
		\item 4 identical 10-kopek coins
	\end{itemize}
	How many distinct ways are there to arrange these coins in a row?
	\footnotetext{Russian currency. Comparable to a penny, since 100 kopeks make a ruble.}


	\vfill


	\problem{}
	Now, derive the \textit{multinomial coefficient} $\binom{n}{k_1,k_2,...,k_m}$. \par
	\vspace{1mm}
	The multinomial coefficient tells us how many distinct ways there to arrange $n$ objects
	of $m$ classes, where each class $i$ contains $k_i$ identical objects. \par
	\hint{
		In \ref{manyballs}, $n = 5$ and $(k_1, k_2, k_3, k_4) = (8, 3, 6, 4)$. \\
		So, the solution to \ref{manyballs} should be given by the multinomial coefficient $\binom{5}{8,3,6,4}$.
	}





	\vfill
	\pagebreak

	\section{Applications}

	\problem{}
	How many ways can a class of 27 people be seated in 30 seats?

	\vfill

	\problem{}
	The following is the map of a city. Each line is a one-way road, you can only drive up or right. \par
	How many different paths can you take from A to B? \par
	How many of them go through the center point?

	\begin{tikzpicture}
		\draw [step=0.5,gray] (0,0) grid (7*0.5,4*0.5);

		\path [draw=black, fill=black] (0 * 0.5, 0 * 0.5) circle (2pt) node[below] {A};
		\path [draw=black, fill=black] (3 * 0.5, 2 * 0.5) circle (2pt);
		\path [draw=black, fill=black] (7 * 0.5, 4 * 0.5) circle (2pt) node[above] {B};
	\end{tikzpicture}

	\vfill

	\problem{}
	How many ways can you put 19 identical balls into 6 bins, leaving no bin empty?

	\vfill

	\problem{}
	Given an exam with 4 problems, how many ways are there to assign positive point values to each problem so that the exam contains a total of 100 points?

	\vfill

	\problem{}
	How many ways can we split the number 2016 into a sum of positive integers? \par
	\note{Consider $2016 + 1$ and $1 + 2016$ distinct sums. Order matters.}

	\begin{solution}
		Split 2016 into ones, and put a \say{bit} between each pair. \par
		This gives us $2^{2015}$ positions to place a bar, and thus $2^{2016}$ possible sums.

		\vspace{2mm}

		You could also sum over the usual stars-and-bars technique to get the same result. \par
		Showing that they're equal could be a good bonus problem!
	\end{solution}




	\vfill

	\problem{}
	A staircase must be built up a wall. It will start 4.5 meters away from the wall, which is 1.5 meters tall. The height of each step is exactly 30 centimeters. The width of each step must be an integer multiple of 50 centimeters. In how many ways can the staircase be constructed?

	\vfill
	\pagebreak

\end{document}
