Advanced array concatenation python
<p>Say I have four multi-dimensional arrays - </p>

<pre><code>a = [["a","a","a"],
    ["a","a","a"],
    ["a","a","a"]]
b = [["b","b","b"],
    ["b","b","b"],
    ["b","b","b"]]
c = [["c","c","c"],
    ["c","c","c"],
    ["c","c","c"]]
d = [["d","d","d"],
    ["d","d","d"],
    ["d","d","d"]]
</code></pre>

<p>and I want to combine them into a single array like</p>

<pre><code>total = [["a","a","a","b","b","b"],
        ["a","a","a","b","b","b"],
        ["a","a","a","b","b","b"], 
        ["c","c","c","d","d","d"],
        ["c","c","c","d","d","d"],
        ["c","c","c","d","d","d"]]
</code></pre>

<p>How would I do it?</p>

<p><em>I am doing it for  spelunky-style map generation</em></p>

<p>Assuming, that layout of your map is more complicated than 2x2 blocks:</p>

<pre><code>from itertools import chain
from pprint import pprint


a = [["a","a","a"],
     ["a","a","a"],
     ["a","a","a"]]
b = [["b","b","b"],
     ["b","b","b"],
     ["b","b","b"]]
c = [["c","c","c"],
     ["c","c","c"],
     ["c","c","c"]]
d = [["d","d","d"],
     ["d","d","d"],
     ["d","d","d"]]
e = [["e","e","e"],
     ["e","e","e"],
     ["e","e","e"]]
f = [["f","f","f"],
     ["f","f","f"],
     ["f","f","f"]]

layouts = [
    ((a, b), (c, d)),
    ((a, b, c), (d, e, f)),
    ((a, b), (c, d), (e, f)),
]

for layout in layouts:
    total = [list(chain(*row)) for lrow in layout for row in zip(*lrow)]
    pprint(total)
</code></pre>

<p><strong>output:</strong></p>

<pre><code>[['a', 'a', 'a', 'b', 'b', 'b'],
 ['a', 'a', 'a', 'b', 'b', 'b'],
 ['a', 'a', 'a', 'b', 'b', 'b'],
 ['c', 'c', 'c', 'd', 'd', 'd'],
 ['c', 'c', 'c', 'd', 'd', 'd'],
 ['c', 'c', 'c', 'd', 'd', 'd']]

[['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'],
 ['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'],
 ['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'],
 ['d', 'd', 'd', 'e', 'e', 'e', 'f', 'f', 'f'],
 ['d', 'd', 'd', 'e', 'e', 'e', 'f', 'f', 'f'],
 ['d', 'd', 'd', 'e', 'e', 'e', 'f', 'f', 'f']]

[['a', 'a', 'a', 'b', 'b', 'b'],
 ['a', 'a', 'a', 'b', 'b', 'b'],
 ['a', 'a', 'a', 'b', 'b', 'b'],
 ['c', 'c', 'c', 'd', 'd', 'd'],
 ['c', 'c', 'c', 'd', 'd', 'd'],
 ['c', 'c', 'c', 'd', 'd', 'd'],
 ['e', 'e', 'e', 'f', 'f', 'f'],
 ['e', 'e', 'e', 'f', 'f', 'f'],
 ['e', 'e', 'e', 'f', 'f', 'f']]
</code></pre>

python arrays pygame concatenation