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).