<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN"
               "http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd" [
  <!ENTITY mathml "http://www.w3.org/1998/Math/MathML">
]> 
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>Simple Paths in a Grid</title>
	</head>
	<body>
		<h1>Simple Paths in a Grid</h1>
		
		<h3>Given:</h3>
		
		<p>A grid of filled and unfilled points
			<math xmlns="&mathml;">
				<mi>R</mi>
			</math> rows tall and
			<math xmlns="&mathml;">
				<mi>C</mi>
			</math> columns wide
		</p>
		
		<p>With starting point
			<math xmlns="&mathml;">
				<mi>S</mi>
				<mo>&ApplyFunction;</mo>
				<mfenced>
					<mn>0</mn>
					<mn>0</mn>
				</mfenced>
			</math>
		</p>
		
		<p>And finish point
			<math xmlns="&mathml;">
				<mi>F</mi>
				<mo>&ApplyFunction;</mo>
				<mfenced>
					<mrow>
						<mi>R</mi>
						<mo>-</mo>
						<mn>1</mn>
					</mrow>
					<mrow>
						<mi>C</mi>
						<mo>-</mo>
						<mn>1</mn>
					</mrow>
				</mfenced>
			</math>
		</p>
		
		<p>And
			<math xmlns="&mathml;">
				<mi>n</mi>
			</math>
			
			filled points
			
			<math xmlns="&mathml;">
				<msub>
					<mi>X</mi>
					<mi>i</mi>
				</msub>
				<mo>&ApplyFunction;</mo>
				<mfenced>
					<msub>
						<mi>R</mi>
						<mi>i</mi>
					</msub>
					<msub>
						<mi>C</mi>
						<mi>i</mi>
					</msub>
				</mfenced>
				<mo>,</mo>
				<mi>R</mi>
				<mo>&gt;</mo>
				<msub>
					<mi>R</mi>
					<mrow>
						<mi>i</mi>
						<mo>+</mo>
						<mn>1</mn>
					</mrow>
				</msub>
				<mo>&ge;</mo>
				<msub>
					<mi>R</mi>
					<mi>i</mi>
				</msub>
				<mo>&ge;</mo>
				<mn>0</mn>
				<mo>&nbsp;and&nbsp;</mo>
				<mi>C</mi>
				<mo>&gt;</mo>
				<msub>
					<mi>C</mi>
					<mrow>
						<mi>i</mi>
						<mo>+</mo>
						<mn>1</mn>
					</mrow>
				</msub>
				<mo>&ge;</mo>
				<msub>
					<mi>C</mi>
					<mi>i</mi>
				</msub>
				<mo>&ge;</mo>
				<mn>0</mn>
				<mo>,</mo>
				<mo>&forall;</mo>
				<mi>i</mi>
				<mo>&isin;</mo>
				<mfenced open="{" close="}">
					<mn>1</mn>
					<mn>2</mn>
					<mi>&hellip;</mi>
					<mi>n</mi>
				</mfenced>
				<mo>,</mo>
				<mi>n</mi>
				<mo>&ge;</mo>
				<mn>0</mn>
				<mo>&isin;</mo>
				<mi>&#8484;</mi>
			</math>
		</p>
		
		<h3>Find:</h3>
		
		<p>The number of shortest simple paths <math xmlns="&mathml;"><mi>N</mi></math> from starting space <math xmlns="&mathml;"><mi>S</mi></math> to finish space <math xmlns="&mathml;"><mi>F</mi></math>.</p>
		
		<h3>Solution:</h3>
		
		<p>Let
			<math xmlns="&mathml;">
				<mi>P</mi>
				<mo>&ApplyFunction;</mo>
				<mfenced>
					<mfenced>
						<msub>
							<mi>r</mi>
							<mn>1</mn>
						</msub>
						<msub>
							<mi>c</mi>
							<mn>1</mn>
						</msub>
					</mfenced>
					<mfenced>
						<msub>
							<mi>r</mi>
							<mn>2</mn>
						</msub>
						<msub>
							<mi>c</mi>
							<mn>2</mn>
						</msub>
					</mfenced>
				</mfenced>
			</math>
			
			be the number of shortest simple paths from
			
			<math xmlns="&mathml;">
				<mfenced>
					<msub>
						<mi>r</mi>
						<mn>1</mn>
					</msub>
					<msub>
						<mi>c</mi>
						<mn>1</mn>
					</msub>
				</mfenced>
			</math>
			
			to
			
			<math xmlns="&mathml;">
				<mfenced>
					<msub>
						<mi>r</mi>
						<mn>2</mn>
					</msub>
					<msub>
						<mi>c</mi>
						<mn>2</mn>
					</msub>
				</mfenced>
			</math>, ignoring filled points.
		</p>
		
		<p>
			<math xmlns="&mathml;">
				<mrow>
					<mi>P</mi>
					<mo>&ApplyFunction;</mo>
					<mfenced>
						<mfenced>
							<msub>
								<mi>r</mi>
								<mn>1</mn>
							</msub>
							<msub>
								<mi>c</mi>
								<mn>1</mn>
							</msub>
						</mfenced>
						<mfenced>
							<msub>
								<mi>r</mi>
								<mn>2</mn>
							</msub>
							<msub>
								<mi>c</mi>
								<mn>2</mn>
							</msub>
						</mfenced>
					</mfenced>
					<mo>=</mo>
					<mo>{</mo>
					<mtable>
						<mtr>
							<mtd>
								<mrow>
									<mmultiscripts>
										<mi>C</mi>
										
										<mfenced>
											<mrow>
												<msub>
													<mi>r</mi>
													<mn>2</mn>
												</msub>
												<mo>-</mo>
												<msub>
													<mi>r</mi>
													<mn>1</mn>
												</msub>
											</mrow>
										</mfenced>
										
										<none/>
										
										<mprescripts/>
										
										<mfenced>
											<mrow>
												<mfenced>
													<mrow>
														<msub>
															<mi>r</mi>
															<mn>2</mn>
														</msub>
														<mo>-</mo>
														<msub>
															<mi>r</mi>
															<mn>1</mn>
														</msub>
													</mrow>
												</mfenced>
												<mo>+</mo>
												<mfenced>
													<mrow>
														<msub>
															<mi>c</mi>
															<mn>2</mn>
														</msub>
														<mo>-</mo>
														<msub>
															<mi>c</mi>
															<mn>1</mn>
														</msub>
													</mrow>
												</mfenced>
											</mrow>
										</mfenced>
										
										<none/>
									</mmultiscripts>
								</mrow>
							</mtd>
							<mtd>
								<mo>,</mo>
								<msub>
									<mi>r</mi>
									<mn>2</mn>
								</msub>
								<mo>&ge;</mo>
								<msub>
									<mi>r</mi>
									<mn>1</mn>
								</msub>
								<mo>&nbsp;and&nbsp;</mo>
								<msub>
									<mi>c</mi>
									<mn>2</mn>
								</msub>
								<mo>&ge;</mo>
								<msub>
									<mi>c</mi>
									<mn>1</mn>
								</msub>
							</mtd>
						</mtr>
						<mtr>
							<mtd>
								<mn>0</mn>
							</mtd>
							<mtd>
								<mo>,</mo>
								<msub>
									<mi>r</mi>
									<mn>2</mn>
								</msub>
								<mo>&lt;</mo>
								<msub>
									<mi>r</mi>
									<mn>1</mn>
								</msub>
								<mo>&nbsp;or&nbsp;</mo>
								<msub>
									<mi>c</mi>
									<mn>2</mn>
								</msub>
								<mo>&lt;</mo>
								<msub>
									<mi>c</mi>
									<mn>1</mn>
								</msub>
							</mtd>
						</mtr>
					</mtable>			
				</mrow>
			</math>
		</p>
		<br />
		<p>
			<math xmlns="&mathml;">
				<mrow>
					<mi>N</mi>
					<mo>=</mo>
					<mi>P</mi>
					<mo>&ApplyFunction;</mo>
					<mfenced>
						<mrow>
							<mi>S</mi>
							<mo>,</mo>
							<mi>F</mi>
						</mrow>
					</mfenced>
					<mo>-</mo>
					<msubsup>
						<mo>&sum;</mo>
						<mrow>
							<mi>i</mi>
							<mo>=</mo>
							<mn>1</mn>
						</mrow>
						<mi>n</mi>
					</msubsup>
					<mfenced open="[" close="]">
						<mrow>
							<mi>P</mi>
							<mo>&ApplyFunction;</mo>
							<mfenced>
								<mrow>
									<mi>S</mi>
									<mo>,</mo>
									<msub>
										<mi>X</mi>
										<mi>i</mi>
									</msub>
								</mrow>
							</mfenced>
							<mo>&middot;</mo>
							<mi>P</mi>
							<mo>&ApplyFunction;</mo>
							<mfenced>
								<mrow>
									<msub>
										<mi>X</mi>
										<mi>i</mi>
									</msub>
									<mo>,</mo>
									<mi>F</mi>
								</mrow>
							</mfenced>
						</mrow>
					</mfenced>
					<mo>+</mo>
					<msubsup>
						<mo>&sum;</mo>
						<mrow>
							<mi>i</mi>
							<mo>=</mo>
							<mn>1</mn>
						</mrow>
						<mrow>
							<mi>n</mi>
							<mo>-</mo>
							<mn>1</mn>
						</mrow>
					</msubsup>
					<mfenced open="[" close="]">
						<mrow>
							<mi>P</mi>
							<mo>&ApplyFunction;</mo>
							<mfenced>
								<mrow>
									<mi>S</mi>
									<mo>,</mo>
									<msub>
										<mi>X</mi>
										<mi>i</mi>
									</msub>
								</mrow>
							</mfenced>
							<mo>&middot;</mo>
							<mi>P</mi>
							<mo>&ApplyFunction;</mo>
							<mfenced>
								<mrow>
									<msub>
										<mi>X</mi>
										<mi>i</mi>
									</msub>
									<mo>,</mo>
									<msub>
										<mi>X</mi>
										<mrow>
											<mi>i</mi>
											<mo>+</mo>
											<mn>1</mn>
										</mrow>
									</msub>
								</mrow>
							</mfenced>
							<mo>&middot;</mo>
							<mi>P</mi>
							<mo>&ApplyFunction;</mo>
							<mfenced>
								<mrow>
									<msub>
										<mi>X</mi>
										<mrow>
											<mi>i</mi>
											<mo>+</mo>
											<mn>1</mn>
										</mrow>
									</msub>
									<mo>,</mo>
									<mi>F</mi>
								</mrow>
							</mfenced>
						</mrow>
					</mfenced>
				</mrow>
			</math>
		</p>
	</body>
</html>
