티스토리 뷰


정수 x, y, z, n을 입력 받는다.
[0, x] 범위에 속한 정수를 i, [0,y] 범위에 속한 정수를 j, [0, z] 범위에 속한 정수를 k라 할 때,
i+j+k가 n과 다른 [i, j, k] 쌍을 출력한다.
if __name__ == '__main__':
x = int(input())
y = int(input())
z = int(input())
n = int(input())
l = list()
for i in range(x+1):
for j in range(y+1):
for k in range(z+1):
if i + j + k != n:
l.append([i,j,k])
print(l)

List Comprehensions | HackerRank
List Comprehensions | HackerRank
You will learn about list comprehensions.
www.hackerrank.com
'Hackerrank > Python' 카테고리의 다른 글
Nested Lists (0) | 2022.02.06 |
---|---|
Find the Runner-Up Score! (0) | 2022.02.05 |
Print Function (0) | 2022.02.05 |
Write a function (0) | 2022.02.05 |
Loops (0) | 2022.02.05 |