11 Project 2 Towers of Hanoi. 22 Towers of Hanoi is a well known puzzle that can be very difficult to solve manually but can be programmed very easily.

Slides:



Advertisements
Similar presentations
3/25/2017 Chapter 16 Recursion.
Advertisements

The Towers of Hanoi or Apocalypse When?.
CSC 205 Programming II Lecture 10 Towers of Hanoi.
1 Project 6: Tic Tac Toe. 2 Tic Tac Toe A Challange Project 10 Points extra credit on final grade OK to work in groups of 2 or 3.
Recursion. Idea: Some problems can be broken down into smaller versions of the same problem Example: n! 1*2*3*…*(n-1)*n n*factorial of (n-1)
CS 106 Introduction to Computer Science I 04 / 02 / 2008 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 11 / 09 / 2007 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 03 / 28 / 2008 Instructor: Michael Eckmann.
Chapter 10: Recursion CS 201 Program Design with C Department of CS, Montana State University Mahmud Shahriar Hossain.
1 Project 6: Cats in Tree. 2 Project 3: Cats in Tree In this project you will Create a class definition for a Cat class. Populate a BST with Cat information.
1 Project 7: Huffman Code. 2 Extend the most recent version of the Huffman Code program to include decode information in the binary output file and use.
1 Project 5: Median. 2 The median of a collection of numbers is the member for which there are an equal number less than or equal and greater than or.
1 Project 7: My Photo Album Graded Project. 2 Assignment Write a web app to permit users to upload and view photos. User can keep up to five photos on.
1 Project 4: XML Product Browser (Not Graded). Objectives This project is an exercise of the following knowledge and skills: Accessing and displaying.
1 Object Oriented Design COP 3331 Spring 2011 MWF 11:50 AM – 12:40 PM CHE 103 Instructor:Dr. Rollins Turner Dept. of Computer Science and Engineering ENB.
Module #20 - Recurrences 1 Ch. 7 Recurrence Relations Rosen 6 th ed., §§7.1.
1 Software Systems Development CEN Spring 2011 TR 12:30 PM – 1:45 PM ENB 116 Instructor:Dr. Rollins Turner Dept. of Computer Science and Engineering.
1 Project 4: Vehicle Inventory. 2 Write a program to read a text file containing information about vehicles and output the information First in the order.
Review Introduction to Searching External and Internal Searching Types of Searching Linear or sequential search Binary Search Algorithms for Linear Search.
Problem Statement: Users can get too busy at work or at home to check the current weather condition for sever weather. Many of the free weather software.
1 Project 3: Chomp (Not graded). 2 Project 3 The game of Chomp was described in a Math Trek column in Science News:
1 Project 5: New Venue. 2 New Venue Based on the posted New Venue scenario 077_Ticket_Booth_Scenarios.pdf.
1 Project 7: Northwind Traders Order Entry. 2 Northwind Order Entry Extend the Select Customer program from Project 6 to permit the user to enter orders.
Advanced Topics- Functions Introduction to MATLAB 7 Engineering 161.
11 Project 2 Temperature Conversion (Not graded).
1 Project 5: Printing Address Labels. 2 Assignment Write a Windows forms program to display and print a set of address labels. Input from a csv file.
15-Dec-15 Blackboard. Web sites All substantive information about this course is on the course website, 2008/index.html.
1 Project 3 The Kumquat Society Conference. 2 Conference Registration In this project you will write a program to handle a conference registration. The.
Recursion Colin Capham Recursion – an introduction to the concept.
Project 3: Ticket Printer
1 COP 3331 Object Oriented Design Spring 2016 Section 001 F 8:00 AM – 10:45 AM CPR 115 Classroom Lecture 3 credit hours Instructor:Dr. Rollins Turner ENB.
1 CAP 4063 Web Application Design Spring 2016 Section 001 TR 11:00 AN – 12:15 PM ENG 4 (classroom lecture) 3 credit hours Instructor:Dr. Rollins Turner.
1-Feb-16 Blackboard. Web sites All substantive information about this course is on the course website,
1 Project 2: Using Variables and Expressions. 222 Project 2 Overview For this project you will work with three programs Circle Paint Ideal_Weight What.
1 Project 3 String Methods. Project 3: String Methods Write a program to do the following string manipulations: Prompt the user to enter a phrase and.
1 Project 1: Tickets. 2 Class Ticket Write a definition for class Ticket. A Ticket object corresponds to a physical ticket for a stage show. Attributes.
1 Project 2: Sorting Cats. Write a C++ console application to read a text file containing information about cats and output the information to the screen.
1 Project 4 Address Lookup. Project 4 Write an ASP.NET app that permits users to retrieve addresses from a potentially large list of addresses. There.
1 Project 3: Farey Sequences. 2 Farey Sequences Further details about Farey sequences, and more examples, can be found in the Wikipedia article:
1 Project 7: Looping. Project 7 For this project you will produce two Java programs. The requirements for each program will be described separately on.
11 Project 2 Temperature Conversion. 22 Project 2: Temperature Conversion Write an ASP.NET Web Forms app to convert temperatures from Fahrenheit to Celsius.
1 Project 5: Leap Years. 222 Leap Years Write a program that reads an integer value from the user representing a year and determines if the year is a.
1 Project 4: Computing Distance. 222 Computing Distance Write a program to compute the distance between two points. Recall that the distance between the.
CMPF144 FUNDAMENTALS OF COMPUTING THEORY Module 9: The Tower of Hanoi.
1 Project 4: Palindrome Detector. 2 Assignment Write a C++ program that reads a line of text from the keyboard and reports to the user whether the text.
1 Recursion Recursive function: a function that calls itself (directly or indirectly). Recursion is often a good alternative to iteration (loops). Its.
1 Project 4: Venue Sort. 2 This project is an exercise in Using C++ strings. Operator overloading. Text File Input.
Recursion Chapter What is recursion? Recursion occurs when a method calls itself, either directly or indirectly. Used to solve difficult, repetitive.
1 Project 5 Eyeglass Rx User Control. Eyeglass Rx Earlier in the semester we looked at an eyeglass prescription as an example of an HTML table. 2.
1 Project 15: Animals Using Derived Classes and Inheritance.
Recursively Defined Sequences Lecture 40 Section 8.1 Wed, Apr 11, 2007.
Aumm-e-hani munir Maria umer Rakhshanda batool Faiza.
1 Towers of Hanoi Three pegs, one with n disks of decreasing diameter; two other pegs are empty Task: move all disks to the third peg under the following.
1 CSC 143 Recursion [Reading: Chapter 17]. 2 Recursion  A recursive definition is one which is defined in terms of itself.  Example:  Sum of the first.
1 Project 6: New Venue. 2 New Venue Based on the posted New Venue scenario
1 Project 8: Tic Tac Toe. 2 Assignment Write an HTML and JavaScript page that pemits users to play Tic Tac Toe. Both players use a single browser. Alternating.
1 Project 7: Ticket_Booth_0 Using XML. 2 Ticket Booth 0 Base Level 0 of the real Ticket Booth program. Gets information for a single venue from an XML.
1 Project 12: Cars from File. This is an extension of Project 11, Car Class You may use the posted solution for Project 11 as a starting point for this.
1 Project 6: Northwind Orders. 2 The Northwind Traders Database The Northwind Traders database was created by Microsoft for training and demonstration.
Tower of Hanoi problem: Move the pile of rings from one peg to another
Data Structures Recursion CIS265/506: Chapter 06 - Recursion.
Programming in JavaScript
Static Class Members March 29, 2006 ComS 207: Programming I (in Java)
Tower of Hanoi problem: Move the pile of rings from one peg to another
The Hanoi Tower Problem
Programming in JavaScript
Programming in JavaScript
Programming in JavaScript
Recursion.
Tower of Hanoi problem: Move the pile of rings from one peg to another
Presentation transcript:

11 Project 2 Towers of Hanoi

22 Towers of Hanoi is a well known puzzle that can be very difficult to solve manually but can be programmed very easily with a recursive solution. Write a C# console application to show the moves to solve the puzzle for an arbitrary number of disks. Call the pegs A, B, and C. Let the user specify the number of disks.

3 Specifications Get the number of disks from the user. Require the number to be greater than 0 and no more than 10. Start with all disks on Peg A Output a message describing each move. After each move show the configuration of the pegs. Your output should match the sample runs for the same input.

4 Character Graphics Represent disk n by a string of 2n-1 X's X XXX XXXXX XXXXXXX Example: A stack of four disks.

5 Sample Run Continued on next slide.

6 Sample Run (continued)

7 Sample Run

8 Specifications Define a class to represent a peg and the disks stacked on top of it. Essentially identical to a stack. Each Peg should have a name, consisting of a single character. Enforce the constraint that you can't put a larger disk on top of a smaller one. Throw exception on violation of this rule or stack overflow. (Shouldn’t happen)

9 Specifications Avoid throwing an exception on invalid input. Use int.TryParse() to convert strings to ints. Make your output match the sample runs.

10 Ground Rules You may work with one other student. OK to work alone if you prefer. If you do work as a pair Work together! Both members are expected to contribute. Both members should understand the program in detail. Submit a single program. Do not share your code with other students. Before or after submitting the project. OK to discuss the project. Do not copy any other student’s work. Don’t look at anyone else’s program. Don’t let anyone look at your program.

11 Ground Rules Except for code posted on the class web site Do not copy code from the Internet or any other source. Write your own code.

12 Submission Project is due by 11:59 PM, Wednesday, Jan. 26. Late projects will not be accepted. Deliverables: Zipped project folder. Use the Windows "Send to Compressed Folder" command to zip your folder. Submit your file via Blackboard Assignments. Not If you work with another student, include both names in the submission comments. Other student submit Blackboard comment with both names. End of Presentation