You are viewing a single comment's thread. Return to all comments →
The problem was written very academically. I feel your pain. Weirdly enough they provide an example later on that is actually the answer....
Ive been finding myself working backwards when I 'figure' a hard problem. I usually don't know why the solution works, so I try to reverse engineer all the elements that work it.
[[l,j,k] for l in range(x+1) for j in range(y+1) for k in range(z+1) if ((j+l+k) != n)]
we create a placeholder list [l,j,k] that iterates over a range from zero to the provided integers. since range is not inclusive, we can find this range by saying range(x+1) since it will provide a list of 0...1...2. we then define how each placeholder int iterates by each subsequent range declaration. After we provide the context of the iteration, we provide an if statement that the sum of all three iterables can't equal n. How the heck the computer does that magic...I don't know.
Someone correct me but this is the best I understand the solution. Even if I'm very wrong, just explaining it helps me understand it.