Here is your homework

Sebastian BergmannArne BlankertsStefan Priebsch |

Today is the first day of school in 2021 here in Bavaria. Due to the lockdown that we have all over Germany and the homeschooling that comes with it, we have found that it helps to motivate our kids to do their homework when they see us adults work as well. So here is your homework.

Here is your homework

Since most of us have probably watched "The Queen's Gambit", we felt that a Chess challenge would be appropriate.

We would like you to write software that, given a Chess piece and its position on an otherwise empty board, prints all possible moves for that piece. Pick your favourite one: King, Rook, Bishop, Queen, Knight, or Pawn.

Not challenging enough? Then expand your solution so that it also works for non-empty boards. Note that the respective rules for capturing need to be taken into account. For the purposes of this exercise, we do not care whether the board state can be reached through actual play.

Your solution does not need to be complete, but what you send us has to work. Text output on the CLI is good enough for us. Automated tests are optional, but welcome.

Why, you may wonder, should you do this homework? Fair question.

We invite you to email your solution as an archive to team@thephp.cc by Friday, January 15, 2021 12:00 PM (CET). We will review all solutions we receive and discuss selected examples in our code review session at The Online PHP Conference, completely anonymous and in a constructive fashion.

Of course, you will need a ticket for the conference to participate in the code review session. But we will make sure that the whole conference will be worthwhile.