Problem-Solving with Karel Announcements Programming Assignment #1 - - PowerPoint PPT Presentation

problem solving with karel
SMART_READER_LITE
LIVE PREVIEW

Problem-Solving with Karel Announcements Programming Assignment #1 - - PowerPoint PPT Presentation

Problem-Solving with Karel Announcements Programming Assignment #1 Out: Karel the Robot: Due Friday, January 20 at 3:15 PM Email: Due Sunday, January 22 at 11:59PM Sign up for section! http://cs198.stanford.edu/section Signups


slide-1
SLIDE 1

Problem-Solving with Karel

slide-2
SLIDE 2

Announcements

  • Programming Assignment #1 Out:
  • Karel the Robot: Due Friday, January 20 at

3:15 PM

  • Email: Due Sunday, January 22 at 11:59PM
  • Sign up for section!

http://cs198.stanford.edu/section Signups close this Sunday at 5PM.

slide-3
SLIDE 3

Friday Four Square

  • Good snacks!
  • Good company!
  • Good game!
  • Good fun!
  • Today at 4:15

in front of Gates.

Don't be this guy!

slide-4
SLIDE 4

Revisiting HurdleJumpingKarel

slide-5
SLIDE 5

RowSweepingKarel

slide-6
SLIDE 6

. . . . . . . .

1 2 3 4 5 6 7 8 1

Before

slide-7
SLIDE 7

. . . . . . . .

1 2 3 4 5 6 7 8 1

After

slide-8
SLIDE 8

Let's Code it Up!

slide-9
SLIDE 9

. . . . . . .

1

Karel has to take six steps… …but has to sweep seven corners.

1 2 3 4 5 6 7

slide-10
SLIDE 10

A More Elaborate Problem

slide-11
SLIDE 11

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8

slide-12
SLIDE 12

RoombaKarel

slide-13
SLIDE 13

The Problem

  • Setup:
  • Karel begins at (1, 1).
  • Karel's world has no walls in it.
  • Each corner has zero or one beepers.
  • Goal:
  • Karel's world is free of beepers.
  • Karel's location does not matter.
slide-14
SLIDE 14

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8

slide-15
SLIDE 15

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8

slide-16
SLIDE 16

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8

slide-17
SLIDE 17

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8

slide-18
SLIDE 18

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8

slide-19
SLIDE 19

Algorithms

  • An algorithm is a process for solving

some problem.

  • Named for 9th-century Persian

mathematician يمزراوخلاىسومنبدمحم, (Muhammad ibn Musa al-Khwarizmi).

  • There are many algorithms for solving

each problem; each offers tradeoffs.

slide-20
SLIDE 20

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8

slide-21
SLIDE 21

BeeperDoublingKarel

slide-22
SLIDE 22

. . .

1 2 3 1

137

Before

slide-23
SLIDE 23

. . .

1 2 3 1

274

After

slide-24
SLIDE 24

How do you double beepers?

slide-25
SLIDE 25

. . .

1 2 3 1

3

slide-26
SLIDE 26

. . .

1 2 3 1

2 2

slide-27
SLIDE 27

. . .

1 2 3 1

1 4

slide-28
SLIDE 28

. . .

1 2 3 1

6

slide-29
SLIDE 29

. . .

1 2 3 1

6