Karel Coding – Hour of Code Solution Manual

Please report bugs to support@nclab.com. Thank you!

Program 1

right
go
get
left
go
go
put
right
go

Program 2

go
left
go
get
go
right
go

Program 3

go
left
go
get
right
right
go
go
put
left
left
go
right
go

Program 4

repeat 3
  go
  get
  go
  go
  put
  go

Program 5

repeat 3
  go
  get
  go
  left

Program 6

repeat 4
  go
  get
  right
  go
  left

Program 7

repeat 10
  if ribbon
    get
  go

Program 8

repeat 7
  go
  left
  go
  right
  if orchid
    get

Program 9

repeat 4
  repeat 5
    go
    if bottle
      get
  left
right
go

Program 10

while wall
  left
  go
  right
go

Program 11

while not home
  go
  if sword
    get
  if wall
    left

Program 12

while not home
  go
  if wall
    left
    if wall
      right
      right
  if key
    get

Program 13

def climb
  while not wall
    go
  right
  go
  left
  go
  return

while not home
  climb

Program 14

def four
  repeat 4
    go
    get
  return

four
right
four
left
four
go

Program 15

# Walk and collect all pies:
def pies
  go
  if pie
    get
  return

# Turn left. If there is 
# a wall, turn around:
def turn
  left
  while wall
    right
  return

# Main program:
while not home
  pies
  turn