problem solving with karel
play

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


  1. Problem-Solving with Karel

  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.

  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!

  4. Revisiting HurdleJumpingKarel

  5. RowSweepingKarel

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

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

  8. Let's Code it Up!

  9. Karel has to take six steps… . . . . . . . 1 1 2 3 4 5 6 7 …but has to sweep seven corners.

  10. A More Elaborate Problem

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

  12. RoombaKarel

  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.

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

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

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

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

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

  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.

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

  21. BeeperDoublingKarel

  22. Before . . . 137 1 1 2 3

  23. After . . . 274 1 1 2 3

  24. How do you double beepers?

  25. . . . 3 1 1 2 3

  26. . . . 2 2 1 1 2 3

  27. . . . 4 1 1 1 2 3

  28. . . . 6 1 1 2 3

  29. . . . 6 1 1 2 3

Recommend


More recommend