By Michael Coco. Setting up the board  Two dimensional array board[x][y]  First column second row is 10  Walls will be labeled with 2  Open positions.

Slides:



Advertisements
Similar presentations
CS0007: Introduction to Computer Programming Arrays: Higher Dimensional Arrays.
Advertisements

Two-Dimensional Arrays Chapter What is a two-dimensional array? A two-dimensional array has “rows” and “columns,” and can be thought of as a series.
 Chapter 7 introduces the stack data type.  Several example applications of stacks are given in that chapter.  This presentation shows another use called.
P Chapter 6 introduces the stack data type. p Several example applications of stacks are given in that chapter. p This presentation shows another use called.
The N-Queens Problem lab01.
CS 206 Introduction to Computer Science II 10 / 15 / 2008 Instructor: Michael Eckmann.
CSC212 Data Structure - Section FG Lecture 12 Stacks and Queues Instructor: Zhigang Zhu Department of Computer Science City College of New York.
CS 106 Introduction to Computer Science I 12 / 13 / 2006 Instructor: Michael Eckmann.
EXAMPLE 4 Solve proportions SOLUTION a x 16 = Multiply. Divide each side by 10. a x 16 = = 10 x5 16 = 10 x80 = x8 Write original proportion.
EXAMPLE 4 Solve proportions SOLUTION a x 16 = Multiply. Divide each side by 10. a x 16 = = 10 x5 16 = 10 x80 = x8 Write original proportion.
Systems of Linear Equations
EXAMPLE 2 Using the Cross Products Property = 40.8 m Write original proportion. Cross products property Multiply. 6.8m 6.8 = Divide.
Algebra 1: Solving Equations with variables on BOTH sides.
Call Stacks John Keyser. Stacks A very basic data structure. – Data structure: a container for holding data in a program. – Classes, structs can be thought.
Objective The student will be able to: solve two-step inequalities.
Stack and Queue.
Splash Screen Lesson 3 Contents Example 1Elimination Using Addition Example 2Write and Solve a System of Equations Example 3Elimination Using Subtraction.
1 Press Ctrl-A ©G Dear 2010 – Not to be sold/Free to use Solving 1 / x > 2 Stage 6 - Year 11 Mathematic Extension 1 (Preliminary)
Math Pacing Elimination Using Addition and Subtraction 1.The sum of two numbers is 31. The greater number is 5 more than the lesser number. What are the.
Do Now: Factor x2 – 196 4x2 + 38x x2 – 36 (x + 14)(x – 14)
Chapter 4 Inequalities 4.1 Inequalities and Their Graphs.
# 1# 1 VBA Recursion What is the “base case”? What is the programming stack? CS 105 Spring 2010.
MT311 Java Application Development and Programming Languages Li Tak Sing ( 李德成 )
Two Dimensional Arrays
Systems of Linear Equations Using a Graph to Solve.
A compound statement is made up of more than one equation or inequality. A disjunction is a compound statement that uses the word or. Disjunction: x ≤
Announcements This Wednesday, Class and Labs are cancelled! The last lab is due this Wednesday … how many people are planning on doing it? Finally posted.
6.6 Solving Radical Equations. Principle of power: If a = b then a n = b n for any n Question: Is it also true that if a n = b n then a = b? Explain in.
Equations Reducible to Quadratic
Two Dimensional Arrays. Two-dimensional Arrays Declaration: int matrix[4][11]; 4 x 11 rows columns
In geometry, two objects are similar when one is a scale model of the other. SIMILAR SHAPES.
Ratio and Proportion 7-1.
Combine Like terms Simplify 3x+2x= 3x+2y+2x+7y= 3x+5x-2= 14x+y-2x+4y-7= Slide 1- 2.
3.2 Solving Equations by Using Addition and Subtraction Addition Property of Equality –If the same number is added to each side of an equation, the resulting.
CS 100Lecture 191 CS100J Lecture 19 n Previous Lecture –Two dimensional arrays. –Reasonable size problem (a past assignment). –Stepwise refinement. –Use.
Using Substitution – Solve the system of linear equations. 1.
EXAMPLE 1 Solve a two-step equation Solve + 5 = 11. x 2 Write original equation. + 5 = x – 5 = x 2 11 – 5 Subtract 5 from each side. = x 2 6 Simplify.
Solving Quadratic Equations by Factoring. Zero-Product Property If ab=0, then either a=0, b=0 or both=0 States that if the product of two factors is zero.
How do I multiply a triple digit number by a double digit? 145 x 67 = ? 267 x 19 = ? I’m sure that you’ll agree that there are many methods that we can.
ONE STEP EQUATIONS Multiplication and Division ONE STEP EQUATIONS Example 1 Solve 3x = 12 Variable? x 3x = 12 x x 3 ÷ 3 Inverse operation? Operation?
Holt McDougal Algebra Solving Equations with Variables on Both Sides 1-5 Solving Equations with Variables on Both Sides Holt Algebra 1 Warm Up Warm.
Scalable lock-free Stack Algorithm Wael Yehia York University February 8, 2010.
x + 5 = 105x = 10  x = (  x ) 2 = ( 5 ) 2 x = 5 x = 2 x = 25 (5) + 5 = 105(2) = 10  25 = 5 10 = = 10 5 = 5.
Warm Up Solve, showing all steps. 1. n + 9 = x = – z = n = 8 x = 7 z = 16 Course Solving Two-Step Equations = 9 y = 72 y8y8.
4.3 Solving Systems of Linear Inequalities 11/7/12.
4.1 An Introduction to Matrices Katie Montella Mod. 6 5/25/07.
Intro to Computer Science II
Data Structures and Algorithms
Stacks and Queues.
Fundamentals of Programming II Backtracking with Stacks
Using a Stack Chapter 6 introduces the stack data type.
Solving Equations by Factoring and Problem Solving
Using a Stack Chapter 6 introduces the stack data type.
Do Now 1) t + 3 = – 2 2) 18 – 4v = 42.
1.4 Solving Absolute-Value Equations
Inequalities with Variables on the Right Side
Using a Stack Chapter 6 introduces the stack data type.
Objective The student will be able to:
Using a Stack Chapter 6 introduces the stack data type.
Bellwork Solve by graphing y < x + 2 y > -1/2x + 5.
SECTION 2-4 : SOLVING EQUATIONS WITH THE VARIABLE ON BOTH SIDES
Tic Tac Toe application
Solving Equations with Variables on Both Sides
1.4 Solving Absolute-Value Equations
Solving Equations with Variables on Both Sides
Algebra EquationsJeopardy
Exercise Solve x – 14 = 35. x = 49.
Solving Systems by Substitution
Objective SWBAT solve polynomial equations in factored form.
Solving Rational Equations
Presentation transcript:

By Michael Coco

Setting up the board  Two dimensional array board[x][y]  First column second row is 10  Walls will be labeled with 2  Open positions will be labeled with 0  Occupied positions with label 1

Setting up the board

Example of the board (cross)

Setting up the Algorithm

Initial Declarations Free0; Moves0; Pegs0; Occupied1; Wall2; Board[][]; xx[]={0,1,0,-1} yy[]={-1,0,1,0} dirSouthdirEast Are both defined by the size of the array

Main Function for x=0 to N for t=0 to N if board[x][t] == 1 pegs++; end if if (moves(pegs)) finished(); else “No solution yet”

moves(pegs) If pegs==1 Return True; for x=0 to N for t=0 to N if board[x][t] == 1 for q=dirSouth to dirEast x2 = x+xx[q]; y2 = y+yy[q]; if board[x2][y2] == 1 x3 = x2+xx[q]; y3 = y2+yy[q];

moves(pegs) continued if board[x3][y3]==0 board[x][y]=0; board[x2][y2]=0; board[x3][y3]=1; pegs--; push(board,x,y,q) if pegs==1 return True;

push(board,x,y,q) The stack will hold the board[x][y] values and the positions that it was switched with incase moves must be backed up.

Examle of board x=6; y=6 xx=0; yy=-1 X2 = 6; y2 = 5 X3 = 6; y2 =

Example (continued)

Moves(peg) continued… The Algorithm continues, checking up, down and side to side. When it comes to a single occupied position it will backup and try another angle pop(); board[x][y]=1; board[x2][y2] = 1; board[x3][y3] = 0; pegs++; Return False

pop Pops the moves off the stack when moves have to be backed up.

 The moves with q value are the moves that you must make to solve the algorithm. However this is not the only solution, it is simply the first one this algorithm has found