Let $n$ be a positive integer and consider an arrangement of $2n$ blocks in a straight line, where $n$ of them are red and the rest blue. A swap refers to choosing two consecutive blocks and then swapping their positions. Let $A$ be the minimum number of swaps needed to make the first $n$ blocks all red and $B$ be the minimum number of swaps needed to make the first $n$ blocks all blue. Show that $A+B$ is independent of the starting arrangement and determine its value.
1. **Define the Problem and Variables:**
   - Let \( n \) be a positive integer.
   - Consider an arrangement of \( 2n \) blocks in a straight line, where \( n \) of them are red and the rest are blue.
   - Define \( A \) as the minimum number of swaps needed to make the first \( n \) blocks all red.
   - Define \( B \) as the minimum number of swaps needed to make the first \( n \) blocks all blue.

2. **Define Reddy and Bluey Pairs:**
   - A pair of distinct blocks is called *reddy* if the block nearer to the left is red and the block nearer to the right is blue.
   - A pair of distinct blocks is called *bluey* if the block nearer to the left is blue and the block nearer to the right is red.
   - Note that there are \( n^2 \) *reddy* or *bluey* pairs of blocks. This is because there are \( n \) red blocks and \( n \) blue blocks, and each red block can pair with each blue block exactly once.

3. **Swapping Mechanism:**
   - When we swap two consecutive blocks, we can remove at most one *reddy* pair (which occurs when the two blocks we swap are a *reddy* pair).
   - Similarly, we can remove at most one *bluey* pair when the two blocks we swap are a *bluey* pair.

4. **Counting Reddy and Bluey Pairs:**
   - To make the first \( n \) blocks all red, we need to remove all *bluey* pairs. Hence, \( A \) is the number of *bluey* pairs at the beginning.
   - To make the first \( n \) blocks all blue, we need to remove all *reddy* pairs. Hence, \( B \) is the number of *reddy* pairs at the beginning.

5. **Summing the Minimum Swaps:**
   - Since there are \( n^2 \) pairs in total and each pair is either *reddy* or *bluey*, the sum of the number of *reddy* pairs and *bluey* pairs is always \( n^2 \).
   - Therefore, \( A + B = n^2 \).

\[
A + B = n^2
\]

The final answer is \(\boxed{n^2}\).