Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

question: 3 if karel starts at street 1 and avenue 3 facing east, what …

Question

question: 3
if karel starts at street 1 and avenue 3 facing east, what street (row) and avenue (column) will karel be on after this code runs?

move();
move();
move();
turnleft();
move();

street 1 and avenue 3
street 4 and avenue 4
street 2 and avenue 6
street 6 and avenue 2

Explanation:

Track initial state

  • Position: Street 1, Avenue 3
  • Direction: East

Execute moves facing East

  • move(): Street 1, Avenue 4
  • move(): Street 1, Avenue 5
  • move(): Street 1, Avenue 6

Execute turn and final move

  • turnLeft(): Faces North
  • move(): Street 2, Avenue 6

Answer:

  • Street 1 and Avenue 3
  • Street 4 and Avenue 4
  • Street 2 and Avenue 6 (Correct answer)
  • Street 6 and Avenue 2