Hi,
I need to write a python function to fold the grid in one of these
four ways, depending on the argument.
L -> Left to Right
R -> Right to Left
T -> Top to Bottom
B -> Bottom to Top
When folding, half the elements will be laid on top of
the others.
After folding until only 1 element remains, I want to print the list
of elements from top to bottom.
Here's a 2x2 example.
Input:
1 2
3 4
fold("R").fold( "B") -> 3, 4, 2, 1
fold("T").fold( "L") -> 3, 1, 2, 4
Is there any "easy" way to do this using reduce function?
thanks
I need to write a python function to fold the grid in one of these
four ways, depending on the argument.
L -> Left to Right
R -> Right to Left
T -> Top to Bottom
B -> Bottom to Top
When folding, half the elements will be laid on top of
the others.
After folding until only 1 element remains, I want to print the list
of elements from top to bottom.
Here's a 2x2 example.
Input:
1 2
3 4
fold("R").fold( "B") -> 3, 4, 2, 1
fold("T").fold( "L") -> 3, 1, 2, 4
Is there any "easy" way to do this using reduce function?
thanks
Comment