Download presentation

Presentation is loading. Please wait.

Published byNoel nolan Leadbeater Modified over 3 years ago

2
4 Games and Fuses U:\APPS\Ghostgum\gsview Shared folder U:\2nd Year Share\Computer Science Courses\Semester One\Algortithmic Problem Solving Book: Algorithmic Problem Solving by Roland Backhouse. Other books: any puzzle book or you can Google logic puzzles, problems, brainteasers, conundrums. Or search for the content of the problems e.g. river crossing problems. Office hour Tue 130-230, Fri 1130-1230. Office AB 325. If you have any “nice” problems please let me have them. Any questions, please ask me?

3
FUSE CLOCKS A fuse is lit at one end and will burn for a specific amount of time i.e. n minutes. The rate at which a fuse burns is irregular i.e. it cannot be lit in the middle with any confidence that the amount of time taken to burn will be half. Two n minute fuses both take n minutes to burn, so the average rate is the same. But at any moment the instantaneous rates may differ. A fuse is a length of wire which take a certain amount of time to burn along its length, not to be confused with an electrical fuse which is thin and burns out if too many amps flow thought it.

4
Example With a single n minute fuse, we could light it at one end and it would take n minutes to burn. Alternatively we could light it at both ends simultaneously and it would take n/2 minutes to burn. Also, given two fuses, we can light the simultaneous so that they are burning together, or light one after the other (i.e. we can burn fuses in serial or partially in parallel). This way we can create new time periods. Imagine we have 2 60 minute fuses. How can we build a 45 minute fuse?

5
Solution Solution. Light the first fuse at one end and the second fuse at both ends. When the second fuse has burnt out, light the other end of the first fuse. When this has burnt out it makes a total of 45 minutes.

6
How many How many other clocks can you make with a pair of fuses? Remember you cannot have a negative time period (e.g. you can burn two fuses in parallel lighting the ends at the same time, giving n-m minutes but we assume this is a positive number). Clocks can be constructed by starting one clock after another, starting two clocks together but starting the timing when one clock has completed. We can also halve the time of a clock by lighting it at both ends. These three construction techniques correspond to addition, subtraction and halving of times.

7
HOURCLASS CLOCKS An hour glass is a glass timer which contains sand. The sand runs under gravity from one end to the other. Unlike a fuse it can be reused (i.e. it can be turned upside down at any point). In this game you are given 2 hourglasses one of 7 minutes and the other of 11 minutes. Your task is to use these 2 hourglasses to measure times of 15 minutes and 24 minutes. Can you do that?

8
Simple two player games. The goal is to have some method (i.e. algorithm) do decide what to do next. The key to winning is to recognise the invariants. We introduce a number of matchstick games. We identify winning and losing positions in a game. A winning strategy is therefore maintaining an invariant.

9
Matchstick Games. Played with one or more piles of matches. Two players make alternate moves. A player can remove one or more matches from one of the piles, according to a given rule. The game ends when there are no more matches to be removed. The player who cannot take any matches is the loser, i.e. the player who took the lasts matches is the winner.

10
Terminology This is an impartial, two person game with complete information. Impartial means rules for moving apply the same to both players. Complete information means that both players have complete information about the game i.e. they know the complete state of the game. An impartial game that is guaranteed to terminate, it is always possible to characterise the positions as winning or losing positions.

11
Winning and Losing Moves A winning position is one from which we can assure a win. A losing position is one from which we can never win. A winning strategy is an algorithm for choosing moves from winning positions that guarantees a win (i.e. we maintain an invariant).

12
Identify Positions Suppose there is one pile of matches, and you can remove 1 or 2 matches. How do we identify winning and losing positions? The losing positions are a multiple of 3. The remaining positions are winning positions.

13
Some Variations Some variations on the matchstick game. There is one pile of matches, each player is allowed to remove 1, 3, 4 matches. What are the winning positions and what are the winning strategies. There is one pile of matches, each player is allowed to remove 1, 3, 4 matches, except that you are not allowed to repeat the last move. So if you opponent removes 1 match you must remove 3 or 4. What are the winning positions and what are the winning strategies.

14
winning strategies Draw a state transition diagram p44 Nodes are labelled with the number of matches remaining. Edges are labelled with the number of matches removed on that turn. We can now label the nodes as winning or losing.

15
State Diagram A node is winning if there is an edge to a losing position A node is losing if every edge from the node leads to a winning node (i.e. we cannot escape from the losing situation). Note that this seems like a circular definition Node 0 is losing, as there are no edges from it. Nodes 1 and 2 are winning, as there is an edge to node 0 Node 3 is losing, as both edges from 3 are to nodes 1 and 2 which are already labelled as winning. Draw thick lines indicating winning positions and winning moves. P45 A clear pattern emerges; losing positions are where the number of matches is a multiple of 3.

16
Winning Strategy Beginning from a state in which n is a multiple of 3, and making and arbitrary move, results in a state in which n is not a multiple of 3. Thus removing n mod 3 matches results in a state in which n is again a multiple of 3.

17
Initial Situation If both players are perfect, the winner is decided by the starting position. If the starting position is a losing position, the second player is guaranteed to win. Starting from a losing position, you can only hope that your opponent makes a mistake, and puts you in a winning position. Think of the situation is OXO.

18
Formally The terminology we use to describe the winning strategy is to “maintain invariant” property that the number of matches is a multiple of 3. Formally we can write this as (the number of moves remaining before the game ends is even) equals (the position is a losing position) I.e. we alternate between winning and losing states or positions.

19
Subtraction Subset {1, 3, 4} Subtraction subset Now we can remove 1 or 3 or 4 matches. Go thru the process of labelling states as winning or losing and build up the table on page 49. Draw the diagram.

20
Winning Strategy Calculate the remainder r after dividing by 7. If r is 0 or 2, the position is a losing position. Otherwise it is a winning position. The winning strategy is to remove 1 match if r=1, Remove 3 matches if r=3 or r=5, remove 4 matches if r = 4 or r =6.

21
The Daisy Problem. Suppose a daisy (a flower) has 16 petals arranged symmetrically around its center. Two players take it in turns to remove petals. A move means taking one petal or two adjacent petals. The winner is the person who removes the last petal. Who should win and what is the winning strategy.

22
The Coin Problem. Two players have an unlimited supply of circular coins of varying diameter (both players have the same set of coins). The players take it in turn to place a coin on a rectangular table, such that it does not overlap any coins already on the table and does not overhang. The winner is the one who puts the last coin on the table. Who should win and what is the winning strategy?

23
EXPLORER 1 An explorer walk one mile south, one mile east and one mile north, but find that he has returned to the point where he started. Why is this? Where was he standing?

24
Explorer 2 The point of this problem is that we may find one solution then stop, but in fact there is an infinite set of solutions. Also ask why it is colder at the poles than at the equator (there are two reasons at least1. further away, 2, light glances 3 light has further to travel thru the atmosphere.)

25
COLOURING THE FACES OF A CUBE Colouring cubes How many different ways are there to colour a cube. I think there are too many just to count, so you need a more principled way to get the solution.

Similar presentations

OK

Discrete Mathematical Structures: Theory and Applications

Discrete Mathematical Structures: Theory and Applications

© 2018 SlidePlayer.com Inc.

All rights reserved.

To ensure the functioning of the site, we use **cookies**. We share information about your activities on the site with our partners and Google partners: social networks and companies engaged in advertising and web analytics. For more information, see the Privacy Policy and Google Privacy & Terms.
Your consent to our cookies if you continue to use this website.

Ads by Google

Pps to ppt online Ppt on bluetooth download Ppt on product specifications Ppt on current account deficit india Large intestine anatomy and physiology ppt on cells Free ppt on different types of houses Ppt on staff motivation Ppt on 2nd world war date Ppt on fire extinguisher types and uses Ppt on singapore stock exchange