This is a memo for myself.
▼ Question
--Create a unique two-dimensional array of [i, j, k]. --The condition of i, j, k is determined by the given positive integers x, y, z
▼sample input
python
x,y,z,n=1,1,1,2
▼sample output
python
[[0, 0, 0], [0, 0, 1], [0, 1, 0], [1, 0, 0], [1, 1, 1]]
▼my answer
python
if __name__ == '__main__':
x = int(input())
y = int(input())
z = int(input())
n = int(input())
res=[]
for i in range(x+1):
for j in range(y+1):
for k in range(z+1):
if i+j+k != n:
res.append([i,j,k])
print(res)
python
if __name__ == '__main__':
x,y,z,n = [int(input()) for _ in range(4)]
print([[i,j,k] for k in range(z+1) for j in range(y+1) for i in range(x+1)if i+j+k != n])
・ ** for _ in range (n) ** Turn the process n times. Since variables are unnecessary, insert "_" for convenience. └ Blank is an error
Blank for
i=-1
for in range(4):
i+=1
print(i)
#output
SyntaxError: invalid syntax
Recommended Posts