![](/img/trans.png)
[英]Create a dict whose value is the set of all possible anagrams for a given word
[英]create matrix whose position value is given by a function
我必須從下面給出的 function 創建一個 5X5 矩陣。
f(x,y) = x(1-y) + y(1-x); 其中 0 < x,y <=5
其中 x 表示行 position 並且 y 表示列。 如何創建一個矩陣,使左下角為 f(0,0),左上角的值為 f(5,5)
M,N = 5,5
matrix = [[((x*(1-y))+(y*(1-x))) for y in range(M)] for x in range(N)]
for i in range(N):
print(matrix[i])
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.