# List Comprehension

This is my solution for List Comprehensions in Python challenges at HackerRank

You are 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, 0 ≤ i ≤ X; 0 ≤ j ≤ Y; 0 ≤ k ≤ Z

**Input Format**

Four integers X, Y, Z and N each on four separate lines, respectively.

**Constraints**

Print the list in lexicographic increasing order.

**Sample Input**

`1`

1

1

2

**Sample Output**

`[[0, 0, 0], [0, 0, 1], [0, 1, 0], [1, 0, 0], [1, 1, 1]]`

**Solution in Python 3**

if __name__ == ‘__main__’:

x = int(input())

y = int(input())

z = int(input())

n = int(input())

result = [[i, j, k]

for i in range(x+1)

for j in range(y+1)

for k in range(z+1)

if (i + j + k) != n

]

print(result)

**References:**

List Comprehensions, https://www.hackerrank.com/challenges/list-comprehensions, accessed on April, 29, 2017

List Comprehension, http://www.python-course.eu/python3_list_comprehension.php, accessed on April, 29, 2017