Daily Challenge #62

Welcome to the 62nd #daily-challenge. Today’s task will be the following:
Create a procedure that asks for 2 inputs, x and y (0<x≤8 ,0<y≤8 [no need to check these in the program])
The program should return 0 if the square is white and 1 if the square is black.

Sample inputs and outputs:

board(1,5) => 0
board(2,4) => 0
board(3,4) => 1

There’s a single rule:
:warning: YailLists are forbidden, meaning you can’t use lists to solve this problem.

As always, have fun!


Assumin x=y will be wrong for this challenge?

No, that’s absolutely okay.

board(7,7) => 0

It’s really easy to make a solution hardcoding the values. Isn’t it better to be a solution that works for the same pattern with any given number? Example x=1 and y=9 will also give 1 or x=9 and y=1 to give 1. I will not share a solution this time so early.

1 Like

I am not sure, I will test my answer and see if it works for any number, just the pattern needs to repeat.

EDIT: Yes, it’s more than okay.

1 Like

That’s exactly what programming is, not hardcoding values or doing something like this:
blocks (15)
That’s why I said:

You can make If statements checking the numbers in the table. This is also hardcoding. Because if the table would be 100x100 with the same pattern always you had to make a lot of If statements. But there is a solution that works with any number without using list or check all the numbers in the table.

i am on my way, without the list and hardcoding values

1 Like

Currently my procedure is at 39 blocks. Let me know if yours has less.

Your Daily challenges are always complicated

The only thing that matters is the functionality. It might not be optimized but it just needs to work.

Nope, you will be shocked how simple the solution is!

1 Like

I am sooooo struggling! I think I need a right idea, because I am thinking in the wrong way. I believe that there is a too simplie soultion for this but I can’t get it! :disappointed_relieved:

1 Like

Mine has 39 blocks too! OMG I’m so happy that I found a way that you probably found too! :heart_eyes:


Mine has 34 now but maybe there is a better solution


If your solution works you can post it here under two tags: details & spoiler

1 Like

Yeah it can be that I used global variable but not local or idk what.

Ok. my solution is here: tell me if something is wrong, because I have no emulator, and my companion is not useable now. So I couldn’t check the solution. :grimacing:

Solution (maybe)

1 Like
My solution

Tested on 30 different examples.


blocks (17)

[n,m] = map(int, input().split())
if (n+m)%3==1:print(1)

I knew ther was a muuuuch easier solution. But I never was interested in maths so I even didn’t knew what modulo was. now I know it. Thx @Mateja!

1 Like

I also used modulo but i didn’t think it that way. That’s why i have so many blocks

My Solution
1 Like