ok, I have working code.
but jens your code says the solution is wrong.
added my own output routine to the udf end to see it.
score with it is 1320.

as example, with the first test my UDF outputs:
B W->BW -> WB->W B

and still your tester says 0% right.

could you please fix the tester so I can clame the bonus points?!?!?!