9.1.6 Checkerboard V1

0 views
Skip to first unread message

Oswald Lemus

unread,
Aug 3, 2024, 4:10:05 PM8/3/24
to singretpackca

I'm using just normal python to make a checkerboard grids out of alternating 1s and 0s. I know that I can use a nested for loop with the modulus operator but I don't know exactly what to do with the modulus inside the for loop.

Here's my solution, using nested for loops. Note that whether i+j is even or odd is a good way to determine where it should be 1 and where it should be 0, as it always alternates between adjacent 'cells'.

Now the only thing that is left is producing it as a string. We can do this by converting the data in the list to strings, join them together (and optionally use generators instead of list comprehension). So:

c80f0f1006
Reply all
Reply to author
Forward
0 new messages