Repository: sagemath/sage

Issue:
SemistandardMultiSkewTableaux returns incorrect results
### Steps To Reproduce

Creating a list of SemistandardMultiSkewTableaux with a specified weight with more than two (skew) shapes in the tuple will generate an incorrect list of tableaux.
In particular, after the second entry, all tableaux in the tuple are just repeats entries of the second tableau, which violates the weight condition.

Here are examples to illustrate this problem.

```
sage: SemistandardMultiSkewTableaux([[[1],[0]]]*2,[1]*2).list() # correct
[[[[1]], [[2]]], [[[2]], [[1]]]]
sage: SemistandardMultiSkewTableaux([[[1],[0]]]*3,[1]*3).list() # incorrect tableaux but correct number of tableaux
[[[[1]], [[2]], [[2]]], [[[2]], [[1]], [[1]]], [[[1]], [[3]], [[3]]], [[[2]], [[3]], [[3]]], [[[3]], [[1]], [[1]]], [[[3]], [[2]], [[2]]]]
sage: for n in range(2,8):
....:    print(len(SemistandardMultiSkewTableaux([[[1],[0]]]*n,[1]*n).list())) # should be factorial(n)
2
6
24
120
720
5040
sage: SemistandardMultiSkewTableaux([[[1],[0]],[[2],[0]],[[1],[0]]],[1,1,1,1]).list() # example where shapes vary; note third shape just copies last entry of second shape.
[[[[1]], [[2, 3]], [[3]]], [[[2]], [[1, 3]], [[3]]], [[[3]], [[1, 2]], [[2]]], [[[1]], [[2, 4]], [[4]]], [[[2]], [[1, 4]], [[4]]], [[[1]], [[3, 4]], [[4]]], [[[2]], [[3, 4]], [[4]]], [[[3]], [[1, 4]], [[4]]], [[[3]], [[2, 4]], [[4]]], [[[4]], [[1, 2]], [[2]]], [[[4]], [[1, 3]], [[3]]], [[[4]], [[2, 3]], [[3]]]]
```



### Expected Behavior

The code should produce all tuples of semistandard tableaux that have the given weight.

### Actual Behavior

The code outputs an incorrect list of all such tuples of tableaux.

### Additional Information

_No response_

### Environment

```markdown
- **OS**: Cocalc Ubuntu 22.04
- **Sage Version**: 10.0
```


### Checklist

- [X] I have searched the existing issues for a bug report that matches the one I want to file, without success.
- [X] I have read the documentation and troubleshoot guide


Discussion:

Resolving patch:
diff --git a/src/sage/combinat/ribbon_tableau.py b/src/sage/combinat/ribbon_tableau.py
--- a/src/sage/combinat/ribbon_tableau.py
+++ b/src/sage/combinat/ribbon_tableau.py
@@ -1083,7 +1083,9 @@ def __contains__(self, x):
         return all(xi.is_semistandard() for xi in x)
 
     def __iter__(self):
-        """
+        r"""
+        Iterate over ``self``.
+
         EXAMPLES::
 
             sage: sp = SkewPartitions(3).list()
@@ -1098,6 +1100,21 @@ def __iter__(self):
             34
             sage: RibbonTableaux(a,weight,k).cardinality()
             34
+
+        TESTS:
+
+        Check that :issue:`36196` is fixed::
+
+            sage: shapes = [[[1], [0]], [[1], [0]], [[1], [0]]]
+            sage: weight = [1, 1, 1]
+            sage: SMST = SemistandardMultiSkewTableaux(shapes, weight)
+            sage: list(SMST)
+            [[[[1]], [[2]], [[3]]],
+             [[[2]], [[1]], [[3]]],
+             [[[1]], [[3]], [[2]]],
+             [[[2]], [[3]], [[1]]],
+             [[[3]], [[1]], [[2]]],
+             [[[3]], [[2]], [[1]]]]
         """
         parts = self._shape
         mu = self._weight
@@ -1122,9 +1139,12 @@ def __iter__(self):
         S = SkewTableaux()
         for lk in l:
             pos = 0  # Double check this
-            restmp = [S.from_shape_and_word(parts[0], [lk[j] for j in range(s[0])])]
+            lk = list(lk)
+            w = lk[:s[0]]
+            restmp = [S.from_shape_and_word(parts[0], w)]
             for i in range(1, len(parts)):
-                w = [lk[j] for j in range(pos + s[i - 1], pos + s[i - 1] + s[i])]
+                pos += s[i-1]
+                w = lk[pos: pos + s[i]]
                 restmp.append(S.from_shape_and_word(parts[i], w))
             yield self.element_class(self, restmp)
 


Test patch: