[null, null, {"document_url": "https://www.programminggeek.in/2016/08/codevita-2016-round-2-question-mate-in-two.html", "unformatted_src": "https://3.bp.blogspot.com/-ABNIzvTP06Y/V7hjNH1wtOI/AAAAAAAAHiM/Pl7nWhK9GY0x8bUNF-b9ynRXpAL8LfIpgCEw/s640/CodeVita2016-Round2-Programming-Geek.jpg", "src": "https://3.bp.blogspot.com/-ABNIzvTP06Y/V7hjNH1wtOI/AAAAAAAAHiM/Pl7nWhK9GY0x8bUNF-b9ynRXpAL8LfIpgCEw/s640/CodeVita2016-Round2-Programming-Geek.jpg", "formatted_filename": "CodeVita Round Programming Geek", "rendered_width": 640, "rendered_height": 182}, null, {"document_url": "https://www.programminggeek.in/2016/08/codevita-2016-round-2-question-mate-in-two.html", "unformatted_src": "https://4.bp.blogspot.com/-cEOzobKCBj0/V7huAuRlI5I/AAAAAAAAHio/EOflbvzIVEgaq5zbx3AFnjPwUtZr6B1kgCLcB/s320/cv15R2_R1P2_fig1.png", "src": "https://4.bp.blogspot.com/-cEOzobKCBj0/V7huAuRlI5I/AAAAAAAAHio/EOflbvzIVEgaq5zbx3AFnjPwUtZr6B1kgCLcB/s320/cv15R2_R1P2_fig1.png", "formatted_filename": "cv R R P fig", "rendered_width": 250, "rendered_height": 250}, null, {"document_url": "https://www.programminggeek.in/2016/08/codevita-2016-round-2-question-mate-in-two.html", "unformatted_src": "https://1.bp.blogspot.com/-Qgmdt4Rkn2k/V7huA4siyEI/AAAAAAAAHis/H7LDEG7AQiomKQ9twwNmh-TLlAjLDwomgCLcB/s1600/cv15R2_R1P2_fig2.png", "src": "https://1.bp.blogspot.com/-Qgmdt4Rkn2k/V7huA4siyEI/AAAAAAAAHis/H7LDEG7AQiomKQ9twwNmh-TLlAjLDwomgCLcB/s1600/cv15R2_R1P2_fig2.png", "formatted_filename": "cv R R P fig", "rendered_width": 250, "rendered_height": 250}, null, null, null, null, null, null, null, {"document_url": "https://www.programminggeek.in/2016/08/codevita-2016-round-2-question-mate-in-two.html", "unformatted_src": "//lh3.googleusercontent.com/-FFqbSyAX4UU/AAAAAAAAAAI/AAAAAAAAAIA/Y8O6RRHSfPo/s80-c/photo.jpg", "src": "http://lh3.googleusercontent.com/-FFqbSyAX4UU/AAAAAAAAAAI/AAAAAAAAAIA/Y8O6RRHSfPo/s80-c/photo.jpg", "formatted_filename": "photo", "alt_text": "My photo", "rendered_width": 80, "rendered_height": 80}, null, null]
Programming Geek
Rated 4.7/5 based on 1446 reviews CodeVita 2016 Round 2 Question: Mate In Two

Vikash Verma 8/20/2016
Problem : Mate In Two A Chess board position is accurately captured by Forsyth-Edwards notation and is abbreviated as FEN. A FEN "record" defines a particular game position, all in one line of text and using only the ASCII character set. A FEN record consists of six fields. A complete description of the FEN format to represent Chess positions can be found here

For the purpose of this problem, only consider first of the six fields of FEN. Before we describe the problem, let us look at how FEN maps to a board position. The following 5 images show board positions and its corresponding FEN representation. Figure 1.

Let's say, White plays e4. Then the board position looks like shown below Figure 2.

Similarly, 3 more half-moves are depicted in following diagrams

The FENs corresponding to Figure 3, 4 and 5 are represented as

3. rnbqkbnr/pppp1ppp/8/4p3/4P3/8/PPPP1PPP/RNBQKBNR
4. rnbqkbnr/pppp1ppp/8/4p3/4PP2/8/PPPP2PP/RNBQKBNR
5. rnbqkbnr/pppp1ppp/8/8/4Pp2/8/PPPP2PP/RNBQKBNR

Wikipedia describes first field of FEN format as follows

Piece placement (from white's perspective). Each rank is described, starting with rank 8 and ending with rank 1; within each rank, the contents of each square are described from file "a" through file "h". Following the Standard Algebraic Notation (SAN), each piece is identified by a single letter taken from the standard English names (pawn = "P", knight = "N", bishop = "B", rook = "R", queen = "Q" and king = "K").[1] White pieces are designated using upper-case letters ("PNBRQK") while black pieces use lowercase ("pnbrqk"). Empty squares are noted using digits 1 through 8 (the number of empty squares), and "/" separates ranks


Given a board position in FEN format, your task is to find out all move(s) that lead to a forced mate. White to play and win in 2 moves.

Input Format:

Output Format:


Sample Input and Output


Admin : Vikash
Labels: Mate In Two , TCS CODEVITA , TCS CODEVITA 2016 , TCS CodeVita 2016 Question , TCS CodeVita 2016 Round2 Question All Posts Connect on Facebbok

Vikash Verma Follow on Google+
