Sort by

recency

|

1844 Discussions

|

  • + 1 comment
    cuboid = [[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(cuboid)
    

    But i dont really understand why we made range(x+1) and so on?

  • + 0 comments

    don't forget about itertools in python, it's tremendously powerful:

    from itertools import product
    
    
    if __name__ == '__main__':
        x = int(input())
        y = int(input())
        z = int(input())
        n = int(input())
        
        print(
            [
                [i, j, k] 
                for i, j, k in product(range(x + 1), range(y + 1), range(z + 1)) 
                if i + j + k != n
            ]
        )
    
  • + 0 comments

    if name == 'main': x = int(input()) y = int(input()) z = int(input()) n = int(input())

    lst = []
    for i in range (x+1):
        for j in range (y+1):
            for k in range(z+1):
                if i + j + k != n:
                    lst.append([i,j,k])
    print(lst)
    
  • + 3 comments

    hii guys i want to know from where i can learn python becoz i have alredy studied python in 12th but i am stilln not able to solve ques like this

  • + 0 comments

    Simple Solution ...

    x = int(input())

    y = int(input())

    z = int(input())

    n = int(input())

    l = []

    for i in range(0,x+1): for j in range(0,y+1): for k in range(0,z+1): if(i+j+k)!=n: l.append([i,j,k]) print(l)