---
# System prepended metadata

title: 'Week I: Lecture Notes'

---

# Week I: Lecture Notes
## Agenda
- Introductions
- Hospital Karel
- Future Directions

## Pseudocode
- [x] Build hospital
    - [x] What is a hospital? [name=Rohit]
    - 2 equal columns of 3 beepers each?
    - Or from a beeper, make a hospital (2 beepers up, 3 down)

### What functions would be needed?
#### Turn Right
- 4 left turns left Karel facing the same direction
- 3 left turns leaves Karel facing the right

```python
def turn_right():
  turn_left()
  turn_left()
  turn_left()
```


## Buggy idea
```python
from karel.stanfordkarel import *

# File: HospitalKarel.py
# -----------------------------
# Here is a place to program your Section problem

def turn_right():
    for i in range(3):
        turn_left()

def move_with_beeper():
    move()
    put_beeper()

def main():
    """
    You should write your code to make Karel do its task in
    this function. Make sure to delete the 'pass' line before
    starting to write your own code. You should also delete this
    comment and replace it with a better, more descriptive one.
    """
    for i in range(3):
        go_save_lives()

def go_save_lives():
    while no_beepers_present():
        move()
    build_hospital()

def build_hospital():
    turn_left()
    move_with_beeper()
    move_with_beeper()
    turn_right()
    move_with_beeper()
    turn_right()
    move_with_beeper()
    move_with_beeper()
    turn_left()



if __name__ == '__main__':
    run_karel_program('HospitalKarel.w')
```

Possible ideas:
- Is Karel in the same state as in the beginning, really? (look below Karel)
    - What is different and how to fix that?
- What other refactoring is possible?