N-Queens Problem. Latin Squares Duncan Prince, Tamara Gomez February

Similar documents
Lecture 6: Latin Squares and the n-queens Problem

MAGIC SQUARES KATIE HAYMAKER

arxiv: v1 [math.co] 24 Nov 2018

Senior Math Circles February 10, 2010 Game Theory II

17. Symmetries. Thus, the example above corresponds to the matrix: We shall now look at how permutations relate to trees.

Fermat s little theorem. RSA.

MATHEMATICS ON THE CHESSBOARD

Solutions to Exercises Chapter 6: Latin squares and SDRs

LESSON 2: THE INCLUSION-EXCLUSION PRINCIPLE

Week 1. 1 What Is Combinatorics?

Which Rectangular Chessboards Have a Bishop s Tour?

12th Bay Area Mathematical Olympiad

ACM ICPC World Finals Warmup 2 At UVa Online Judge. 7 th May 2011 You get 14 Pages 10 Problems & 300 Minutes

Asymptotic Results for the Queen Packing Problem

University of British Columbia. Math 312, Midterm, 6th of June 2017

MAS336 Computational Problem Solving. Problem 3: Eight Queens

CSE 573 Problem Set 1. Answers on 10/17/08

The number of mates of latin squares of sizes 7 and 8

Tile Number and Space-Efficient Knot Mosaics

Lecture 1, CS 2050, Intro Discrete Math for Computer Science

SMT 2014 Advanced Topics Test Solutions February 15, 2014

14th Bay Area Mathematical Olympiad. BAMO Exam. February 28, Problems with Solutions

Junior Circle Games with coins and chessboards

1 Introduction. 2 An Easy Start. KenKen. Charlotte Teachers Institute, 2015

Permutations. = f 1 f = I A

ENGR170 Assignment Problem Solving with Recursion Dr Michael M. Marefat

arxiv: v2 [math.gt] 21 Mar 2018

Constructing pandiagonal magic squares of arbitrarily large size

Reflections on the N + k Queens Problem

What is counting? (how many ways of doing things) how many possible ways to choose 4 people from 10?

Separation Numbers of Chessboard Graphs. Doug Chatham Morehead State University September 29, 2006

STRATEGY AND COMPLEXITY OF THE GAME OF SQUARES

TILING RECTANGLES AND HALF STRIPS WITH CONGRUENT POLYOMINOES. Michael Reid. Brown University. February 23, 1996

How Many Mates Can a Latin Square Have?

arxiv: v2 [cs.cc] 20 Nov 2018

1.6 Congruence Modulo m

Constraint Satisfaction Problems: Formulation

Recovery and Characterization of Non-Planar Resistor Networks

Dutch Sudoku Advent 1. Thermometers Sudoku (Arvid Baars)

Ivan Guo. Broken bridges There are thirteen bridges connecting the banks of River Pluvia and its six piers, as shown in the diagram below:

Second Annual University of Oregon Programming Contest, 1998

To be able to determine the quadratic character of an arbitrary number mod p (p an odd prime), we. The first (and most delicate) case concerns 2

Lecture 2: Sum rule, partition method, difference method, bijection method, product rules

Tilings with T and Skew Tetrominoes

SOLUTIONS TO PROBLEM SET 5. Section 9.1

arxiv: v1 [math.gt] 21 Mar 2018

Odd king tours on even chessboards

More Recursion: NQueens

Math 127: Equivalence Relations

I.M.O. Winter Training Camp 2008: Invariants and Monovariants

Grade 6 Math Circles March 7/8, Magic and Latin Squares

A theorem on the cores of partitions

Introduction to Counting and Probability

Topspin: Oval-Track Puzzle, Taking Apart The Topspin One Tile At A Time

You ve seen them played in coffee shops, on planes, and

Discrete Mathematics. Spring 2017

Permutation group and determinants. (Dated: September 19, 2018)

Formulas for Primes. Eric Rowland Hofstra University. Eric Rowland Formulas for Primes / 27

BMT 2018 Combinatorics Test Solutions March 18, 2018

YourTurnMyTurn.com: chess rules. Jan Willem Schoonhoven Copyright 2018 YourTurnMyTurn.com

Kenken For Teachers. Tom Davis January 8, Abstract

INTERNATIONAL MATHEMATICS TOURNAMENT OF TOWNS Junior A-Level Paper, Spring 2014.

DELUXE 3 IN 1 GAME SET

Chapter 5 Backtracking. The Backtracking Technique The n-queens Problem The Sum-of-Subsets Problem Graph Coloring The 0-1 Knapsack Problem

UK JUNIOR MATHEMATICAL CHALLENGE. April 25th 2013 EXTENDED SOLUTIONS

Using KenKen to Build Reasoning Skills 1

ON MODULI FOR WHICH THE FIBONACCI SEQUENCE CONTAINS A COMPLETE SYSTEM OF RESIDUES S. A. BURR Belt Telephone Laboratories, Inc., Whippany, New Jersey

CSE548, AMS542: Analysis of Algorithms, Fall 2016 Date: Sep 25. Homework #1. ( Due: Oct 10 ) Figure 1: The laser game.

Edge-disjoint tree representation of three tree degree sequences

Taking Sudoku Seriously

OCTAGON 5 IN 1 GAME SET

arxiv: v2 [math.ho] 23 Aug 2018

ISudoku. Jonathon Makepeace Matthew Harris Jamie Sparrow Julian Hillebrand

A construction of infinite families of directed strongly regular graphs

Caltech Harvey Mudd Mathematics Competition February 20, 2010

ON SPLITTING UP PILES OF STONES

STAJSIC, DAVORIN, M.A. Combinatorial Game Theory (2010) Directed by Dr. Clifford Smyth. pp.40

Chapter 3 PRINCIPLE OF INCLUSION AND EXCLUSION

Non-overlapping permutation patterns

Problem F. Chessboard Coloring

EXPLORING TIC-TAC-TOE VARIANTS

Solutions to the 2004 CMO written March 31, 2004

Staircase Rook Polynomials and Cayley s Game of Mousetrap

NON-OVERLAPPING PERMUTATION PATTERNS. To Doron Zeilberger, for his Sixtieth Birthday

Stupid Columnsort Tricks Dartmouth College Department of Computer Science, Technical Report TR

A year ago I investigated a mathematical problem relating to Latin squares. Most people, whether knowing it or not, have actually seen a Latin square

WPF PUZZLE GP 2018 ROUND 2 INSTRUCTION BOOKLET. Host Country: Switzerland. Markus Roth, Roger Kohler, Esther Naef

Problem Solving Methods

SOME CONSTRUCTIONS OF MUTUALLY ORTHOGONAL LATIN SQUARES AND SUPERIMPOSED CODES

18.204: CHIP FIRING GAMES


UNIVERSITY OF NORTHERN COLORADO MATHEMATICS CONTEST

Math 3560 HW Set 6. Kara. October 17, 2013

Modular Arithmetic: refresher.

NIM Games: Handout 1

Math Circle Beginners Group May 22, 2016 Combinatorics

CMPSCI 250: Introduction to Computation. Lecture #14: The Chinese Remainder Theorem David Mix Barrington 4 October 2013

Some constructions of mutually orthogonal latin squares and superimposed codes

Magic Squares. Lia Malato Leite Victoria Jacquemin Noemie Boillot

Math 1111 Math Exam Study Guide

Transcription:

N-ueens Problem Latin Squares Duncan Prince, Tamara Gomez February 19 2015 Author: Duncan Prince The N-ueens Problem The N-ueens problem originates from a question relating to chess, The 8-ueens problem Chess is played on an 8 8 grid, with each piece taking up one cell A queen is a piece in chess that, in any given move, can move any distance vertically, horizontally, or diagonally However, the queen cannot move more than one direction per turn It can only move one direction per turn So a question one might ask themselves is whether or not you can place 8 queens on a chessboard so that none of the queens can kill each other in one move (ie There is no way for a queen to in one cell to reach a queen in another cell in one move)? The answer is yes! Here is one way this can be achieved: = ueen There are 12 unique solutions to this problem Two solutions are not unique if you can mirror one solution to find the other, or if you can rotate the board to find the other solution, or a combination of the two moves We can generalize the 8-ueens problem to be the N-ueens problem uestion Given an n n chessboard, can we place n queens on the chessboard so that none of the queens can kill each other in one move? Example n = 4: 1

One may think we can find solutions for all values of n, upon trying a few small values of n, we find that no solutions exist for n = 2 or n = 3 Here we see why: n = 2: The only option we have is to place a queen in the corner of board No matter where we put the first queen, it can always move to any other spot on the board in one move Thus, we cannot place a second queen to satisfy the N-ueens problem n = 3: This doesn t work for a reason similar to why n = 2 doesn t work If we place a queen in the center of the board, then it can always move to any other spot on the board in one move So placing a queen at the center of the board does not let us place a second queen So we can try placing a queen in the corner of the board Now we have to cells that the queen cannot reach in one move So we can now place a second queen However, putting a queen in any of those two cells makes it so that both queens can reach any other cell on the board Therefore we do not have the option to place a third queen Any place we put the first queen leaves (at most) two other places to put queens without conflict with the first queen, but the 2nd and 3rd queens will always be able to reach each 2

other in one move, so n = 3 cannot satisfy the N-ueens problem The N-ueens problem seems inherently similar to concepts of Latin Squares It turns out Latin Squares are in fact useful when working with the N-ueens problem! Author: Tamara Gomez Definition A broken right diagonal of Latin square L is the set of n cells that start from choosing any cell in the top row, then taking the cell that is in the row below and one cell to the right Repeat this process until we reach the last row If the cell reaches the last column, then wrap around to the first column of the next row A broken right diagonal is sometimes called a wrap around right diagonal Example Definition A broken left diagonal is the same as a broken right diagonal, except we wrap around to the left instead of the right Example The concept of broken diagonals will give us the special type of Latin square that will help us find solutions to the n-queens problem Definition A Latin square L is called pandiagonal if there are no repeated symbols in any broken diagonal Ie, every symbol appears exactly once in each broken diagonal Example 0 1 2 3 4 3 4 0 1 2 1 2 3 4 0 4 0 1 2 3 2 3 4 0 1 None of the broken diagonals have any repeats, therefore we have a pandiagonal Latin square 3

So now take a pandiagonal Latin square L We know that L does not have repeated symbols in any row or column because it is a Latin square We also know that L does not have repeated symbols in its broken diagonals because it is a pandiagonal Latin square Therefore, if we choose any symbol s in our Latin square, and place a queen on top of each cell that contains an s, then none of the queens will be able to capture each other So we will have placed n queens on an n n grid so that none of them can capture each other So, if a pandiagonal Latin square of order n exists, then we know we can find a solution to the n-queens problem for that order Pandiagonal Latin squares actually give us n (not necessarily distinct) solutions to the n-queens problem But, you may find yourself asking the following question: uestion For what order do pandiagonal Latin squares exist? Well, consider the following construction for L: Take any a, b {0, 1,, n 1} Let the n 2 cells of L be represented by the following grid L = 0 a 2a 3a (n 1)a b b + a b + 2a b + 3a b + (n 1)a 2b 2b + a 2(b + a) 2b + 3a 2b + (n 1)a 3b 3b + a 3b + 2a 3(b + a) 3b + (n 1)a (n 1)b (n 1)b + a (n 1)b + 2a (n 1)b + 3a (n 1)(b + a) mod n In general, L i,j (which denotes the cell in the ith row and jth column) is ai + bj mod n Claim 1: In order for L to be a Latin square, a, b must all be relatively prime to n Proof Since L is Latin square, we know there is no symbol that is repeated in any row In other words, there are no two symbols L i,j and L i,k that are the same Notice that, by our construction, this only happens if ai + bj ai + bk mod n bj bk mod n If b and n share a factor, let us call it f, and we set j = 0, and k = n f then we have bj = 0, and bk will be a multiple of n Therefore bk 0 mod n, so bj bk mod n So b and n cannot share a factor If b and n are relatively prime, then b will have an inverse mod n Therefore if we look at b 1 bj b 1 bk (mod n), then we know that j must be congruent to k because b 1 b 1 (mod n) So bj bk (mod n) will only happen when j = k, ie, L i,j and L i,k are the same cell Similarly, if we look at the columns of L, we will see that a and n must also be relatively prime by the same argument Claim 2: In order for L to be a pandiagonal Latin square, a + b and a b must be relatively prime to n Proof Take any broken right diagonal in L Since L i,j is of the form ai + bj, the entry that is below and to the right of L i,j, ie L i+1,j+1, is of the from a(i + 1) + b(i + 1) = 4

ai + bj + a + b = L i,j + a + b With this observation, it is easy to see that any broken right diagonal is of the following form: ka + (n k)(a + b) ka ka + (a + b) ka + (n k 1)(a + b) ka + (n 1)(a + b) So if a + b is relatively prime to n, Then each multiple of (a + b) will be distinct mod n Therefore each entry in our broken right diagonal will be distinct Similarly, if a b is relatively prime to n, each entry in our broken left diagonal will be distinct Therefore, if a + b and a b are relatively prime to n, then L is a pandiagonal Latin square In a perfect world, this construction for pandiagonal Latin squares would exist for every order Sadly, we do not live in such a world They do not exist for even orders or an orders that are divisible by 3 Before we begin that proof, we must look at the following definition first Definition A transversal of a Latin square is a way to pick out n symbols so that you have one from each row, each column, and each symbol is represented Example 3 1 4 2 4 2 3 1 2 4 1 3 1 3 2 4 Observation If a Latin square L has an orthogonal mate, then L can be divided into n distinct transversals Proof Take a Latin square L and its orthogonal mate M Choose any symbol s in M Look at the cells containing s in M Since L and M are orthogonal, we know that these same cells in L cannot have any repeated symbols Since L and M are Latin squares, we know that these symbols do not repeat in any row or column Therefore each symbol s that appears in M corresponds to a transversal in L Since we have n distinct symbols, we have n distinct transversals Corollary If L is a Latin square of a cyclic group (for example, Z/nZ) of even order, then L does not have an orthogonal mate Claim 3: Pandiagonal Latin squares do not exist for even orders 5

Proof Assume L is a pandiagonal Latin square of even order Look at the following Latin square M: M = 0 1 n 1 1 2 0 n 1 0 n 2 Notice that the broken left diagonals of M are the same symbol repeated We also know that the broken left diagonals of L have no repeating symbols, since L is a pandiagonal Latin square Therefore L and M are mutually orthogonal, because each pair (L i,j, M i,j ) will appear only once However, our corollary tells us that M cannot have an orthogonal mate because it is a Latin square of a cyclic group of even order Therefore we have a contradiction, and L cannot be a pandiagonal Latin square of even order Pandiagonal Latin squares also do not exist for orders of n where n is a multiple of 3 We have tried several proof methods, but have yet to succeed in proving this claim Although pandiagonal Latin squares may not exist for every order, the fact that a connection between the n-queens problem and Latin squares exists is very exciting! (It also suggests that Latin squares may be the coolest structures in existence Stay tuned for a proof of this claim) However, the interesting thing about the n-queens problem is not whether or not a solution exists, because it is known that solutions exist for n 4 What is interesting is the number of distinct solutions that exists The number of different solutions, 6

not necessarily distinct, is known for n 26 n Number of different solutions 1 1 2 0 3 0 4 2 5 10 6 4 7 40 8 92 9 352 10 724 11 2680 12 14200 13 73712 14 365596 15 2279184 16 14772512 17 95815104 18 666090624 19 4968057848 20 39029188884 21 314666222712 22 2691008701644 23 24233937684440 24 227514171973736 25 2207893435808352 26 22317699616364044 7

The number of distinct solutions is also known for n 26 n Number of distinct solutions 1 1 2 0 3 0 4 1 5 2 6 1 7 6 8 12 9 46 10 92 11 341 12 1787 13 9233 14 45752 15 285053 16 1846955 17 11977939 18 83263591 19 621012754 20 4878666808 21 39333324973 22 336376244042 23 3029242658210 24 28439272956934 25 275986683743434 26 2789712466510289 It is clear to see that the number of solutions grows exponentially However there is an odd case There are more solutions for n = 5 than for n = 6 This is the only case where something like that happens, but it is very interesting The number of solutions that exist when n 27 is still an open problem But other people have also looked into different variations of the n-queens problem For example, given an n n board, what is the smallest number of queens one can place (denoted by s(n)) so that they cover the entire board, yet none of them can capture each other? Here are the values for n 8: 8

n s(n) Number of different solutions 1 1 1 2 1 1 3 1 1 4 3 2 5 3 2 6 4 17 7 4 1 8 5 91 Another spin-off from the n-queens problem is the n-rooks problem A rook is a chess piece that can only move vertically and horizontally So it is like a queen, except it cannot move along the diagonals It is actually known that there are n! solutions to the n-rooks problem, which is really cool! Now, you may find yourself wondering how someone found all the different possible solutions for the n-queens problem for n 26 Well, the most popular method is with what is called a backtracking program The backtracking program runs the following algorithm to find a solution to the n-queens problem: Place a queen in the top row, and keep track of the column and diagonal that it occupies Place a queen in the next row down, avoiding the same column and diagonal as the queen above, and keep track of the column and diagonal it occupies Move on to the next row If no position is available in the next row, back track to the previous row and move the queen to the next available spot Continue this process until a queen is placed on each row The number of different solutions for n = 26 was found in July of 2009 The number of different solutions for n = 27 is still unknown, but who knows, maybe it will be in the quintillions Sources: Eric W Weissten, ueens Problem From MathWorld, A Wolfram Web Resource The University of Utah, The N by N ueens Problem Padraic Bartlett, 2012 Mathcamp Lecture 5 and Lecture 6 notes :) Jeff Sommers, The N ueens Problem The Online Encyclopedia of Integer Sequences 9