“Python Interview Question Asked by Top Tech Companies: Google, NASA, OpenAI (GPT)!”

PYTHON: PROGRAM 3D COORDINATES LIST

PROGRAM: Given three integers x, y, and z representing the dimensions of a cuboid, along with an integer n.Print a list of all possible coordinates (i, j, k) on a 3D grid where the sum of i + j + k is not equal to n.Constraints:

SOLUTION:

x = int(input(” x “))

y = int(input(” y “))

z = int(input(” z “))

n = int(input(” n ” ))

coordinates = [ [i+j+k]

for i in range(x+1)

for i in range(y+1)

for i in range(z+1)

if (i+j+k) != n ]

print(coordinates)

Facebook
LinkedIn
WhatsApp

Leave a Reply

Your email address will not be published. Required fields are marked *