In order not to have two yellows next to each other,
the three yellows must occupy squares 1, 3, and 5.
That leaves squares 2 and 4 to fill, and two colors
to do it with. There are only four ways.
Blue Blue Red Red Blue Red Red Blue
So, the answer is four ways.
.