17
Brian Thompson [email protected] Puzzle s TO ALGORITHMS August 20-21, 2012 CS4HS Teacher Workshop @ Rutgers University 1

Puzzles

  • Upload
    yamka

  • View
    45

  • Download
    0

Embed Size (px)

DESCRIPTION

TO. Puzzles. ALGORITHMS. Brian Thompson [email protected]. Why Puzzles?. Learning algorithms may be intimidating for students who are new to computer science Puzzles are more familiar and are frequently seen as challenging and fun - PowerPoint PPT Presentation

Citation preview

Page 1: Puzzles

CS4HS Teacher Workshop @ Rutgers University 1

Brian [email protected]

PuzzlesTO

ALGORITHMS

August 20-21, 2012

Page 2: Puzzles

CS4HS Teacher Workshop @ Rutgers University 2

Why Puzzles?

• Learning algorithms may be intimidating for students who are new to computer science

• Puzzles are more familiar and are frequently seen as challenging and fun

• Strategy: use puzzles to introduce computer science concepts, algorithms, and data structures

Puzzles To Algorithms

Page 3: Puzzles

CS4HS Teacher Workshop @ Rutgers University 3

Fair Cake-Splitting

Puzzles To Algorithms

Page 4: Puzzles

CS4HS Teacher Workshop @ Rutgers University 4

Fair Cake-Splitting

• Materials: worksheet, mini-cakes (be aware of allergies), knives, plates/napkins, Java applet: http://pidancer.com/Projects/CakeCutting/

• Puzzle: Split a cake amongst several people, so each is guaranteed to get his/her fair share

• Goal: Introduce the idea of an algorithm, demonstrate that algorithms can be used to solve everyday problems

Puzzles To Algorithms

Page 5: Puzzles

CS4HS Teacher Workshop @ Rutgers University 5

Fair Cake-Splitting• Hand out the worksheet, introduce the problem out loud.• Have students form groups of 3, discuss the 2-person cake-splitting

scenario in groups, raise hand if they have questions.• After 5 minutes, choose a group to present their solution (and why

it is fair for both participants).• While groups discuss 3-person cake-splitting, hand out a mini-cake

with knife and plate/napkin per group to try out their solution.• After 5 minutes, ask for volunteers to present their solution. As a

class, analyze whether the solution is fair. Encourage discussion.• Present the “SAY WHEN” n-person fair cake-splitting algorithm.

Discuss/prove why it is fair.• Test out the “SAY WHEN” algorithm with the whole class using the

Java applet here: http://pidancer.com/Projects/CakeCutting/.

Puzzles To Algorithms

Page 6: Puzzles

CS4HS Teacher Workshop @ Rutgers University 6

Tower of Hanoi

Puzzles To Algorithms

Page 7: Puzzles

Tower of Hanoi

• Materials: Tower of Hanoi game, or make one yourself by bringing 4 stackable items of increasing size

• Puzzle: Transfer a stack of disks (or objects) from one pile to another, following two rules:(1) can only move one disk at a time(2) can’t place any disk on top of a smaller disk

• Goal: Introduce the (related) concepts of recursion and induction; problem-solving strategy of approaching a complex problem by first solving a simpler problem and then generalizing

Puzzles To Algorithms CS4HS Teacher Workshop @ Rutgers University 7

Page 8: Puzzles

CS4HS Teacher Workshop @ Rutgers University 8

Mazes

Puzzles To Algorithms

Page 9: Puzzles

CS4HS Teacher Workshop @ Rutgers University 9

Mazes

• Materials: Worksheet with a maze, should be challenging enough that students will not see the solution immediately

• Puzzle: Design a general procedure to solve mazes that will work no matter how big or tricky the maze is

• Goal: Can be used to teach back-tracking, binary trees, depth-first search

Puzzles To Algorithms

Page 10: Puzzles

CS4HS Teacher Workshop @ Rutgers University 10

The Calendar Game

Puzzles To Algorithms

Page 11: Puzzles

CS4HS Teacher Workshop @ Rutgers University 11

The Calendar Game

• Materials: Calendar (handout or projector), pen or pencil, and scratch paper

• Puzzle: The Calendar Game, a 2-person turn-based game played on a standard calendar

• Goal: Learn how computers play games by thinking about how clever people play games; introduce the concepts of “winning positions” and “losing positions”; show how a different representation can make a problem easier

Puzzles To Algorithms

Page 12: Puzzles

CS4HS Teacher Workshop @ Rutgers University 12

The Calendar Game

• Start at January 1• Alternate turns doing one of the following:– Jump to a later month, same day

(e.g. January 1 August 1)– Jump to a later day, same month

(e.g. January 1 January 12)– Can only jump forward in time– Must stay in the same year

• Whoever ends up on December 31 winsPuzzles To Algorithms

Page 13: Puzzles

CS4HS Teacher Workshop @ Rutgers University 13

The Calendar Game

Puzzles To Algorithms

Start

Winner!

Page 14: Puzzles

CS4HS Teacher Workshop @ Rutgers University 14

The Calendar Game

• Explain the rules of the game• Play an example game with a student to

demonstrate and make sure the rules are clear• Students pair up and play against each other;

go around and clarify rules if necessary• After a few minutes, ask for volunteers to

present their strategy; encourage discussion• Present the analysis on the following slides

Puzzles To Algorithms

Page 15: Puzzles

CS4HS Teacher Workshop @ Rutgers University 15

The Calendar Game

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

JanFebMarAprMayJunJulAugSeptOctNovDec

Puzzles To Algorithms

Start

Winner!

• Let’s represent the calendar a different way• Work backwards: What happens if your opponent moves to Nov. 30?

Page 16: Puzzles

CS4HS Teacher Workshop @ Rutgers University 16

The Calendar Game

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

JanFebMarAprMayJunJulAugSeptOctNovDec

Puzzles To Algorithms

Start

Winner!

• Discuss why the dark blue squares are “winning positions”• If both players are clever, who wins? What is the winning first move?

Page 17: Puzzles

CS4HS Teacher Workshop @ Rutgers University 17Puzzles To Algorithms

Brian [email protected]