Thread.com interview question

One game problem with quite a lot rules to implement