Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lesson 17. Introduction to For Loops: Explain why we need to subtract 1 to board_size.x #955

Open
sin3to1faith opened this issue May 13, 2024 · 2 comments
Labels
content Issues with the lessons, practices, including their code examples

Comments

@sin3to1faith
Copy link

sin3to1faith commented May 13, 2024

In the second example of this section's lesson, board_size.x - 1 is used as a parameter in the range() function when it should be board_size.x as void range(length: int) creates a list of numbers from 0 to length - 1.

This mistake can be seen again in the first practice lesson 'Using a for loop to move to the end of the board'. The user must recreate the mistake shown in this lesson's example to succeed in the practice lesson.

@sin3to1faith sin3to1faith added the content Issues with the lessons, practices, including their code examples label May 13, 2024
@sin3to1faith sin3to1faith changed the title Lesson 17 "Using a for loop instead of a while loop" Lesson 17. Introduction to For Loops: "Using a for loop instead of a while loop" May 13, 2024
@sin3to1faith sin3to1faith changed the title Lesson 17. Introduction to For Loops: "Using a for loop instead of a while loop" Lesson 17. Introduction to For Loops: "Using a for loop instead of a while loop" contains mistakes. May 13, 2024
@NathanLovato
Copy link
Contributor

Thanks for taking the time to give feedback. In this case, the lesson's correct. To move to the end of a grid of 5 cells, if you're on cell 1, you need to move 4 times. range(5) (the size of the array) would produce 5 numbers (0, 1, 2, 3, 4) and make you move 5 steps, so 1 cell past the limit. That's why you need to subtract 1 from the board size.

I'm changing the issue title to add a new sentence about that to the lesson.

@NathanLovato NathanLovato changed the title Lesson 17. Introduction to For Loops: "Using a for loop instead of a while loop" contains mistakes. Lesson 17. Introduction to For Loops: Explain why we need to subtract 1 to board_size.x May 13, 2024
@sin3to1faith
Copy link
Author

sin3to1faith commented May 13, 2024

if you're on cell 1

I'm guessing cell 1 refers to the 0 on y in Vector2? My apologies for the oversight. I assumed there was a "cell 0" and forgot that it was just an index.

Is it correct to presume that we can use range(board_size.x) if the robot is not already on the board?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content Issues with the lessons, practices, including their code examples
Projects
None yet
Development

No branches or pull requests

2 participants