OK, this time I actually thought it through.

spoiler:You divide into **4** groups.

if(groupA != groupB)

{

if(groupA != groupC)

{

X = groupA

}

else

{

X = groupB

}

}

else

{

if(groupA != groupC)

{

X = groupC

}

else

{

// you are ****ed, since you can't tell

// if the resulting group is heavier or

// lighter than the rest

X = groupD

}

}

You note whether the X-group is heavier or lighter than the other groups it's measured against. Then weigh two balls of the X-group (a and b).

If they weigh the same, the result is ball c. Otherwise the one that has the same traits that the X-group had (i.e. heavier or lighter) is the result.