Finding the center of gravity of an object that does not have equal distribution of mass NOTICE: I have very limited knowledge of physics so try not to confuse me, though I know it is inevitable.
Say I have a grid of squares, where a □ has 1g of mass, while a ■ has 5g of mass. If I create a random (but joined together) grid of these squares, how would I find the center of gravity of this shape? E.g:

Thanks in advance!
 A: Just to take the first one as an example.  Assume that the square position corresponds to coordinates, so that first square is at x = 1, etc.  The center of mass is given by
$$ CM = \frac{\Sigma_i (m_i*x_i)}{\Sigma_i m_i} $$
For the first one this equation gives
$$CM=\frac{1*1+1*2+5*3+1*4}{1+1+5+1} = 22/8 =3.75 $$
A: Assume the four squares are at locations 0, 1, 2, and 3. Assume the mass of each square is $M_1$, $M_2$, $M_3$, and $M_4$. If $x$ is the center of mass, then you can write the following equation:
$$(x-0)\times M_1 + (x-1) \times M_2 + (x-2) \times M_3 + (x-3) \times M_4 = 0$$
This is basically saying that if $x$ is the balance point on a teeter-totter, then the torques on the right balance the torques on the left. If you solve for $x$, you will have the location of the center of mass as a distance measured from the center of the left-most cube.
You can rearrange the equation as follows:
$$(M_1+M_2+M_3+M_4) \times x = 0 \times M_1 + 1 \times M_2 + 2 \times M_3 + 3 \times M_4$$
therefore:
$$x = (0 \times M_1 + 1 \times M_2 + 2 \times M_3 + 3 \times M_4)/(M_1+M_2+M_3+M_4)$$
A: Since you say that you have little knowledge of physics I'm going to assume that you're not very facile with algebra etc.,  the solution is to use the "Fermi" method.  Build the shape out of Legos or your favorite toy.  Then cut a square out of cardboard and fold it in half to form a tent.  Now balance the shape on the roof of the tent to find the center of mass.  Repeat for each axis.  This should be good to 10 or 20% with almost no effort.
