Hi I have a task to use a lambda that print's a pascal tringle. The problem I'm having is that I can't use any variables nor can I use a recursive lambda. I need to submit my answer in the following way:
lambda x : <code>
because the answer is submitted in this way I can't use any variables nor can I use recursion.
and the tringle need to look like this:
3: [[1], [1, 1], [1, 2, 1]]
so because I can't use any variables I searched for a way to print the tringle without the other lines.
and I found that you can calculate a pascal tringle in the following way:
1: 0nCr0
2: 1nCr0, 1nCr1
3: 2nCr0, 2nCr1, 2nCr2
so I tried using it to solve my task and I reached this thing:
lambda x : ( [([(int)( ( __import__("math").factorial(i) ) / (__import__("math").factorial(j) * ( __import__("math").factorial(i - j) ) ) ) for j in range(i + 1)]) for i in range(x)] )
the only problem is that I can't use import and I don't know how to use factorial inside a lambda without using the math library.