First, lets make some assumptions:
- (Assumption 1) Suppose each measurement that you make with the ruler is of the form $\theta+E$ where $\theta$ is the "true" measure and $E \sim N(0,\sigma^2)$;
- (Assumption 2) Suppose each measurement you make is independent of the other;
- (Assumption 3) You can freely move the sticks $A$ and $B$;
- (Assumption 4) You can line the sticks in a manner which makes its combined length equals the sum of the individuals length perfectly;
- (Assumption 5) If you mark a point on a stick, you can measure the length from the point to any of its tips.
Assume the "true" lengths of $A$ and $B$ are respectively $\theta_A$ and $\theta_B$ (further assume, without loss of generality, that $\theta_A>\theta_B$).
Under these assumptions:
- Concatenate the sticks and measure their combined lengths ($S$): $$S \sim N(\theta_A+\theta_B,\sigma^2)$$ (Assumptions 1, 3, and 4)
- Put the sticks side by side with their ends aligned. Measure the difference between them ($D$): $$D \sim N(\theta_A-\theta_B,\sigma^2)$$ (Assumptions 1, 3, and 5)
- Calculate $$X_A=\dfrac{S+D}{2} \sim N\left(\theta_A,\dfrac{\sigma^2}{2}\right)$$ and $$X_B=\dfrac{S-D}{2} \sim N\left(\theta_B,\dfrac{\sigma^2}{2}\right)$$ (Assumption 2)
Now you have achieved measures of the length of $A$ (denoted by $X_A$) and the length of $B$ (denoted by $X_{B}$) with smaller variance $\left(\dfrac{\sigma^2}{2}\right)$.
I cannot recall where I have seem this problem before, but I believe its is an usual example in standard textbooks (maybe it was in Casella and Berger's Statistical Inference).
It is worth noting that this technique is in someway the same you have suggested: averaging. This question is usually posed in the form: if you can only take two measurements, how can you improve your estimates? Anyway, hope it was helpful.