Let's apply this to our [code]move_to_end()[/code] function. This time, we compare the number of loops to the board's width. We go through the loop until we reach the width of the board. Note that we move the robot until its position is one less than the board's width because we are counting tiles from [code]0[/code]. A board of [code]3[/code] by [code]3[/code] cells would have cell coordinates going from [code]0[/code] to [code]2[/code] on both the X and Y axes.
Aplikujme to na naši funkci [code]move_to_end()[/code]. Tentokrát porovnáme počet smyček s šířkou šachovnice. Procházíme smyčkami, dokud nedosáhneme šířky desky. Všimněte si, že se pohybujeme o jednu smyčku méně, než je šířka desky, protože robot je již na prvním políčku.
This time, we compare the number of loops to the board's width. We go through the loop until we reach the width of the board.
Note that we move the robot until its position is one less than the board's width because we are counting tiles from [code]0[/code].
A board of [code]3[/code] by [code]3[/code] cells would have cell coordinates going from [code]0[/code] to [code]2[/code] on both the X and Y axes.
Tentokrát porovnáme počet smyček s šířkou šachovnice. Procházíme smyčkami, dokud nedosáhneme šířky desky.
Všimněte si, že se pohybujeme o jednu smyčku méně, než je šířka desky, protože robot je již na prvním políčku.