You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
919 B
28 lines
919 B
'''
|
|
Author: SJ2050
|
|
Date: 2021-10-27 13:08:32
|
|
LastEditTime: 2021-10-27 19:06:32
|
|
Version: v0.0.1
|
|
Description: Solution for homework1.3.
|
|
Copyright © 2021 SJ2050
|
|
'''
|
|
import numpy as np
|
|
|
|
if __name__ == '__main__':
|
|
first_row = np.vectorize(lambda x: (x+1)%2)(np.array([i for i in range(8)]))
|
|
second_row = np.vectorize(lambda x: x%2)(np.array([i for i in range(8)]))
|
|
mat = np.zeros((8, 8), dtype=np.int)
|
|
for i in range(0, 8):
|
|
if i % 2 == 0:
|
|
mat[i] = first_row
|
|
else:
|
|
mat[i] = second_row
|
|
# print(mat)
|
|
# beautify output
|
|
print('—————————————————————————————————')
|
|
for r in range(8):
|
|
for c in range(8):
|
|
print(f'| {mat[r][c]} ', end='')
|
|
print('|')
|
|
print('—————————————————————————————————')
|