# Magic rotated checkerboard function made in python!

Here's a puzzle for all you python programmers out there:

I defined a function that goes like this:

def checkers(num):
magic = [_____________________________________________________________]
print('\n'.join(magic + magic[num-2::-1]))


Here are the results from calling the function with different numbers:

checkers(1)


Output:

_|
_|


checkers(2)


Output:

  _|
_|_|_|
_|


checkers(3)


Output:

    _|
_|_|_|
_|_|_|_|_|
_|_|_|
_|


checkers(4)


Output:

      _|
_|_|_|
_|_|_|_|_|
_|_|_|_|_|_|_|
_|_|_|_|_|
_|_|_|
_|


checkers(5)


Output:

        _|
_|_|_|
_|_|_|_|_|
_|_|_|_|_|_|_|
_|_|_|_|_|_|_|_|_|
_|_|_|_|_|_|_|
_|_|_|_|_|
_|_|_|
_|


I hope you get the gist as to what the function does, but if not:
Whatever number we pass into the brackets, it will print out a checker board rotated 45 degrees, with the number we passed in as each of its dimensions.

For your challenge, find out how magic is defined.

You don't have to define it the same way I did, but just for a little hint on one way to define it, each underscore between the two square-brackets represents a character, with no unnecessary whitespaces (I do love PEP-8, don't get me wrong).

• Are the trailing whitespaces on each row significant? – Bubbler Oct 21 '20 at 1:34
• The 1x1 checkerboard usually has fewer than two squares though. – Bass Oct 21 '20 at 4:06
• @Bubbler The trailing spaces were conclusive, but I guess I accidentally removed some from the last one. I'll add them in. – risky mysteries Oct 21 '20 at 15:32
• @Bass It is one square if you look at it sideways and squint really hard. – risky mysteries Oct 21 '20 at 17:04

From a fellow abuser of listcomps, magic is

" "*(num-i-1)+"_|"*(2*i+1)+" "*(num-i-1)for i in range(num)
It's a list of the rows in the upper half.

The hint is

magic(1) not being square: this occurs because num-2 is -1 and so what would be all but the last row in reverse order becomes the last (and only) row

49 bytes, respecting the spaces on the right side:

('_|'*(2*i+1)).center(num*4-2)for i in range(num)
Try it online!

That said, it isn't a very interesting puzzle since string formatting tasks are common in regular programming, except the bit of inferring what the magic should evaluate to. I hope you come up with more interesting ones later :)