HackerRank- Python List Comprehensions

Given three integers X, Y and Z representing the dimensions of a cuboid along with an integer N. You have to print a list of all possible coordinates given by (i, j, k) on a 3D grid where the sum of i, j, k is not equal to N. Here,

  1. if __name__ == '__main__':
  2. x = int(input())
  3. y = int(input())
  4. z = int(input())
  5. n = int(input())
  6. print([[a, b, c] for a in range(x + 1) for b in range(y + 1) for c in range( z + 1) if a+b+c != n ])
Please click on the like button if it worked

Solution not working or have any suggestions? Please send an email to [email protected]

donate a cup of tea :)

Join Our Facebook Group

Share this solution


Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube