hmm, first, find total number of ways you can arrange all the
balls(without the restrictions). you should know how to this if you
ask this question. let it be x
next, find the number of ways a red ball will be next to a black
ball. this can be done by making the red and black ball a new
'ball'. this means that you will have 8 balls now, 3 red, 4 white
and 1 red/black ball. you can then find the number of ways you can
arrange those balls. let it be y. then, within the new 'ball', you
can have to ways to arrange it(RB or BR). so, the total number of
ways a red ball will be next to a black ball is 2y
so, total number of ways such that no red ball is next to the black
= x - 2y