Answers.Body: <p>There is only one black piece left, so the last move was with the king. Black's last move was obviously Kg1-h2.
  The king could not have come from h3, because there is no way the white pawn could have given check from g2 (its initial position). All other squares around h2 are occupied by white pieces.</p>
  
  <p>Since the black king came from g1, it was in check from the rook on d1 before the last move. Obviously the rook could not have moved to d1 from somewhere on the d file because the pawn on d2 blocks the way. So there are two possibilities how the rook could have given check:</p>
  
  <ol>
  <li>discovered check, i.e. a white piece moved away  form e1 or f1 making space for the attack on the black king on g1</li>
  <li>long castle</li>
  </ol>
  
  <p>As for "1" None of the pieces currently on the board could have moved away from the 1st row (i.e. from e1 or f1) to give way for the check. However if <strong>a white knight moved from f1 to h2 giving check</strong> that would be a discovered check and the black king captured this knight on h2. Obviously this is the only option for a discovered check.</p>
  
  <p>As for "2". If white castled long, that means that the white king never moved (castling rules) before, meaning the white king was always on e1. Then the question is: How did the black king get to g1? With the white king on e1, the black king could not have entered via f1 or f2. Neither it could have come via g2 (where there is still the original white pawn). </p>
  
  <p>This would mean that it came via <strong>h2</strong>. But is that possible? In order to get to h2, it would have to come from h3 (not possible because of the original never-moved pawn on g2) or from <strong>g3</strong>. </p>
  
  <p>However the black king could never have entered via g3, because the square was either i) attacked by a pawn from f2 or ii) occupied by that same pawn from f2.</p>
  
  <p>That leaves as the only option, as last moves 1. Nf1-h2+ Kxh2</p>
  
  <hr>
  
  <p>Going back one move further, what was the last move of black before Nf1-h2+? There are two possibilities: it could be a move by the king or it could be a move by a piece which got captured on h2 by the knight.</p>
  
  <p>Let's analyze both options.</p>
  
  <h2>Black moved the king in move 0</h2>
  
  <p>If the last move was by the black king it could not have come from f1, g2, h1 (which are blocked by white pieces) and neither could it have come from f2, because there is no way the knight on h1 could have given check. That leaves only h2 as possible option. So assuming the king came from h2, where it was in check, the last white move must have been Ne3-f1+. So the moves are now 0. Ne3-f1+ Kh2-g1 1. Nf1-h2+ Kxh2. </p>
  
  <p>That is not the end of the story yet, because looking at the position before 0. Ne3-f1+ you note (basically for the same arguments as before, that the last move of black must have been Kg1-h2. On g1 the king would have been in check. This check (for the same arguments as presented before) could only have been a discovered check by the knight on e3.</p>
  
  <p>So we have a situation where the black king is shuffling between g1 and h2 while the white knight is moving between f1 and e3. How can this infinite loop be broken? The only way to break this is, if there was a black piece at some point on f1, which blocked the check from the rook. This black piece on f1 got captured by the white knight when the black king was on h2.</p>
  
  <h2>Black moved a piece to h2 in move 0</h2>
  
  <p>If black must moved another piece that  got captured on h2, this piece can be a black pawn, knight, rook, or queen. It can not be a black bishop, because it could not have moved to h2 (because g3 and g1 were occupied by pieces).</p>
  
  <h2>Summary</h2>
  
  <p>Two possible solutions:</p>
  
  <pre><code>0. .... N/Q/R/pawn h2
  1. Nf1xh2 Kg1xh2
  </code></pre>
  
  <p>or</p>
  
  <p>Initial position: </p>
  
  <p>white: pawns on d2,g2,g3; Nh1; Ne3; Kc1; Rd1; 
  black: Kh2; some piece on f1</p>
  
  <pre><code>-n. Nx piece f1+ Kh2g1
  [any number of repeating moves with the knight shuffling between f1 and e3 and the king between g1 and h2]
  -1. .... Kg1h2
   0. Ne3f1+ Kh2g1
   1. Nf1h2 Kg1xh2
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-14T22:10:42.250Z
Answers.Text: Thank you in advice. But can you tell me, what position was before Nf1-h2 Kh2?
Answers.UserDisplayName: Skyend
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-15T01:32:42.470Z
Answers.Text: @Skyend:White captured a black piece on h2. Will add to the answer.
Answers.UserDisplayName: user1583209
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-15T09:08:26.630Z
Answers.Text: @user1583209: I don't completely agree with your additional analysis of what happened going back one move further. What you say is just one of two possibilities. Consider a position like the given position in the OP, with the addition of a White Knight on e3. Now 1.Nf1+ Kf1 2.Nh2+ Kxh2 gives the position we have, and the Black King moved twice. This is the only way Black King can have moved twice.
Answers.UserDisplayName: LeibnizGW
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-15T09:10:06.963Z
Answers.Text: @KnightoftheSquareTable: Indeed, will fix.
Answers.UserDisplayName: user1583209
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-15T09:57:26.300Z
Answers.Text: -1. Kg1-h2 0.Ne3-f1+ does not work - while the knight is on e3, the black king could not have entered the first row (due to the then unrestrained rook). You will need some more intermediate moves to explain how the f the king got into the corner.
Answers.UserDisplayName: Annatar
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-15T10:01:48.893Z
Answers.Text: @Annatar The king could have entered the first row from h2 or the knight could have captured a black piece on f1 (so that the check was blocked before that).
Answers.UserDisplayName: user1583209
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-15T10:15:48.503Z
Answers.Text: I don't think that option 1 works (the king can only get to h2 via the first row, a vicious circle), but I have figured out option 2. :D
Answers.UserDisplayName: Annatar
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-15T10:18:39.630Z
Answers.Text: @Annatar Yes there could be a vicious circle (knight moving between f1 and e3 and king between g1 and h2 any number of time), but before that at some point a black piece was captured on f1. Will add to the answer.
Answers.UserDisplayName: user1583209
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-15T10:42:13.880Z
Answers.Text: There could be a black piece on f1 so it was Ne3xf1? Say it was a Re1 originally, then the king walks in over d3-e2-f1-g1, then the rook goes Re1-f1-e1-f1 while everything else is being put into place, then Kh2, Ne3xf1+, Kg1, Nh2, Kxh2. (Edit: oops - this isn't new).
Answers.UserDisplayName: RemcoGerlich
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-14T22:03:01.903Z
Answers.LastActivityDate: 2018-02-15T10:34:01.590Z
Answers.LastEditDate: 2018-02-15T10:34:01.590Z
Answers.UserDisplayName: user1583209
Answers.Body: <p>Building on user1583209's answer, here is a complete sequence of moves to show how the black king managed to trap himself in the corner in the first place:</p>
  
  <pre><code>[FEN "8/8/8/8/2N1N3/3k2P1/3P2P1/2KRq3 b - - 0 1"]
  
  1... Ke2 2. Nc3+ Kf1 3. Ne4 Kg1 4. Ne3 Kh2 5. Nf2 Qg1 6. Nh1 Qf1 7. Nxf1+ Kg1 8. Nh2+ Kxh2
  </code></pre>
  
  <p>Another possibility:</p>
  
  <pre><code>[FEN "8/8/8/7q/2N1N3/3k2P1/3P2P1/2KRq3 b - - 0 1"]    
  
  1... Ke2 2. Nc3+ Kf1 3. Ne4 Kg1 4. Nf2 Kf1 5. Nh1 Kg1 6. Ne3 Qf1 7. Nxf1 Qh2 8. Nxh2+ Kxh2
  </code></pre>
  
  <hr>
  
  <p>Third example by user1583209 without blocking piece:</p>
  
  <pre><code>[FEN "8/8/8/7q/2N1N3/3k2P1/3P2P1/2KR4 b - - 0 1"]
  
  1... Qh6 2. Kb2 Qh7 3. Ra1 Qh6 4. Kc1 Qh7 5. Nf2+
  Ke2 6. Nh1 Kf1 7. Ne3+ Kg1 8. Nf1 Qh6 9. Kb2
  Qh7 10. Rd1 Qh6 11. Kc1 Qh2 12. Nxh2+ Kxh2
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-15T10:42:30.570Z
Answers.Text: But all the moves before Nxf1+ are random and also the black queen could be another black piece, right?
Answers.UserDisplayName: user1583209
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-15T10:43:30.437Z
Answers.Text: Also, this only shows one of the two possible solutions. The other has a black piece on h2 which gets captured by the knight.
Answers.UserDisplayName: user1583209
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-15T11:03:03.293Z
Answers.Text: @user1583209 Yes, there is more than one solution. Added another ;)
Answers.UserDisplayName: Annatar
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-15T11:07:27.360Z
Answers.Text: @user1583209 The moves before Nxf1+ show the safe paths of both the king but also the two knights (without (stale)mate) into the corner. And yes, the queens could also be rooks, obviously.
Answers.UserDisplayName: Annatar
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-15T11:18:17.410Z
Answers.Text: I still think that you should make clear which moves are forced and which are optional. I believe in the first solution anything before Nxf1+ is optional to some extent. In the second solution you don't need a black blocking piece on the first row.
Answers.UserDisplayName: user1583209
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-15T11:44:05.963Z
Answers.Text: @user1583209 Yes I do need a blocking piece so that the black king can safely walk to g1 before the knight lands on f1. Distinguishing between forced and optional moves is not very productive, imo. Most of the "forced" moves are kinda optional anyways because pieces can be shuffled back and forth a few times for each move.
Answers.UserDisplayName: Annatar
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-15T13:32:34.250Z
Answers.Text: No you don't need a blocking piece. See my edit above.
Answers.UserDisplayName: user1583209
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-15T13:34:47.423Z
Answers.Text: @user1583209 Ah, fair enough. The white king can block too. More waiting moves with the queen though.
Answers.UserDisplayName: Annatar
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-15T13:41:01.527Z
Answers.Text: You don't even need to block with the king. You could also move the rook away somewhere. My point is that there are lots of possibilities and an answer/solution to such retro problem should IMO only include the moves that can be deduced with **certainty**. With certainty one can only say that the last move was king takes knight on h2. If you go back one move further you already end up with two options (which I can live with), there is not much point in figuring out all the different ways the king could have come to g1.
Answers.UserDisplayName: user1583209
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-15T10:14:05.740Z
Answers.LastActivityDate: 2018-02-15T13:35:53.040Z
Answers.LastEditDate: 2018-02-15T13:35:53.040Z
Answers.UserDisplayName: Annatar
Answers.Body: <p>For the King to be on h2, it must have previously been on either h3 to g1. Being on h3 would have been impossible, since the g2-pawn has been there the entire game. So, the King must have been on g1.</p>
  
  <p>One could give a counterargument saying that Rd1 has been on the 1st rank for more than one move, since it appears stuck. However, this idea is refuted by the fact that White could have castled with 0-0-0.</p>
  
  <p>But then if White castled queenside, his King must have been on e1 the entire game.... which poses the problem of how Black's King got to g1 in the first place. I'm stuck at this point.</p>
  
  <p>EDIT: I didn't consider the possibility of White ALREADY castling, and then Black moves his King to e2. Maybe there's some White piece on the first rank that allows Black's King to move to g1 without being attacked by Rd1. Then, as user1583209 pointed out, a move like Nf1-Nh2+ Kxh2 would give us the final position.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-28T05:40:41.617Z
Answers.LastActivityDate: 2018-04-28T05:40:41.617Z
Answers.UserDisplayName: Inertial Ignorance
Body: <p>It's White to move. What was Black's last move, and what could have happened before that?</p>
  <pre><code>[FEN &quot;8/8/8/8/8/3P2P1/3P2Pk/2KR3N w - - 0 1&quot;]
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-02-14T21:39:44.917Z
Comments.Text: Is this position white or black to move?
Comments.UserDisplayName: D M
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-02-14T21:43:14.323Z
Comments.Text: King takes knight on h2?
Comments.UserDisplayName: user1583209
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-02-14T21:44:06.313Z
Comments.Text: Black did the last move
Comments.UserDisplayName: Skyend
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-02-14T21:45:40.260Z
Comments.Text: With castling there is no way the black king would get to where he is, because the white king + white pawns would block the way.
Comments.UserDisplayName: user1583209
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-02-14T21:46:11.767Z
Comments.Text: I will write an answer.
Comments.UserDisplayName: user1583209
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-02-14T21:49:20.777Z
Comments.Text: I think white's knight moved from f1 to h2
Comments.UserDisplayName: Skyend
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-02-14T21:50:14.663Z
Comments.Text: @Skyend I wrote this 6 min ago. Am now composing an extended answer.
Comments.UserDisplayName: user1583209
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-02-14T21:58:54.423Z
Comments.Text: So what do you think, what is the first position?
Comments.UserDisplayName: Skyend
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-04-28T03:40:20.060Z
Comments.Text: This deserves better than -1
Comments.UserDisplayName: Laska
Tags: <problems><retrograde-analysis>
Title: What was Black's last move?
ThreadText: # What was Black's last move?
  
  (Asked by: username_0 on 2018-02-14)
  
  It's White to move. What was Black's last move, and what could have happened before that?
  
  ```
  [FEN "8/8/8/8/8/3P2P1/3P2Pk/2KR3N w - - 0 1"]
  
  ```
  
  **Tags:** problems, retrograde-analysis
  
  > **Comments:**
  > **username_1**: Is this position white or black to move?  
  > **username_2**: King takes knight on h2?  
  > **username_0**: Black did the last move  
  > **username_2**: With castling there is no way the black king would get to where he is, because the white king + white pawns would block the way.  
  > **username_2**: I will write an answer.  
  > **username_0**: I think white's knight moved from f1 to h2  
  > **username_2**: @username_0 I wrote this 6 min ago. Am now composing an extended answer.  
  > **username_0**: So what do you think, what is the first position?  
  > **username_3**: This deserves better than -1  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_2 on 2018-02-14. Score: 12
  
  There is only one black piece left, so the last move was with the king. Black's last move was obviously Kg1-h2.
  The king could not have come from h3, because there is no way the white pawn could have given check from g2 (its initial position). All other squares around h2 are occupied by white pieces.
  
  Since the black king came from g1, it was in check from the rook on d1 before the last move. Obviously the rook could not have moved to d1 from somewhere on the d file because the pawn on d2 blocks the way. So there are two possibilities how the rook could have given check:
  
  1. discovered check, i.e. a white piece moved away form e1 or f1 making space for the attack on the black king on g1
  2. long castle
  
  As for "1" None of the pieces currently on the board could have moved away from the 1st row (i.e. from e1 or f1) to give way for the check. However if **a white knight moved from f1 to h2 giving check** that would be a discovered check and the black king captured this knight on h2. Obviously this is the only option for a discovered check.
  
  As for "2". If white castled long, that means that the white king never moved (castling rules) before, meaning the white king was always on e1. Then the question is: How did the black king get to g1? With the white king on e1, the black king could not have entered via f1 or f2. Neither it could have come via g2 (where there is still the original white pawn).
  
  This would mean that it came via **h2**. But is that possible? In order to get to h2, it would have to come from h3 (not possible because of the original never-moved pawn on g2) or from **g3**.
  
  However the black king could never have entered via g3, because the square was either i) attacked by a pawn from f2 or ii) occupied by that same pawn from f2.
  
  That leaves as the only option, as last moves 1. Nf1-h2+ Kxh2
  
  ---
  
  Going back one move further, what was the last move of black before Nf1-h2+? There are two possibilities: it could be a move by the king or it could be a move by a piece which got captured on h2 by the knight.
  
  Let's analyze both options.
  
  ## Black moved the king in move 0
  
  If the last move was by the black king it could not have come from f1, g2, h1 (which are blocked by white pieces) and neither could it have come from f2, because there is no way the knight on h1 could have given check. That leaves only h2 as possible option. So assuming the king came from h2, where it was in check, the last white move must have been Ne3-f1+. So the moves are now 0. Ne3-f1+ Kh2-g1 1. Nf1-h2+ Kxh2.
  
  That is not the end of the story yet, because looking at the position before 0. Ne3-f1+ you note (basically for the same arguments as before, that the last move of black must have been Kg1-h2. On g1 the king would have been in check. This check (for the same arguments as presented before) could only have been a discovered check by the knight on e3.
  
  So we have a situation where the black king is shuffling between g1 and h2 while the white knight is moving between f1 and e3. How can this infinite loop be broken? The only way to break this is, if there was a black piece at some point on f1, which blocked the check from the rook. This black piece on f1 got captured by the white knight when the black king was on h2.
  
  ## Black moved a piece to h2 in move 0
  
  If black must moved another piece that got captured on h2, this piece can be a black pawn, knight, rook, or queen. It can not be a black bishop, because it could not have moved to h2 (because g3 and g1 were occupied by pieces).
  
  ## Summary
  
  Two possible solutions:
  
  ```
  0. .... N/Q/R/pawn h2
  1. Nf1xh2 Kg1xh2
  
  ```
  
  or
  
  Initial position:
  
  white: pawns on d2,g2,g3; Nh1; Ne3; Kc1; Rd1;
  black: Kh2; some piece on f1
  
  ```
  -n. Nx piece f1+ Kh2g1
  [any number of repeating moves with the knight shuffling between f1 and e3 and the king between g1 and h2]
  -1. .... Kg1h2
   0. Ne3f1+ Kh2g1
   1. Nf1h2 Kg1xh2
  
  ```
  
  > **Comments:**
  > **username_0**: Thank you in advice. But can you tell me, what position was before Nf1-h2 Kh2?  
  > **username_2**: @username_0:White captured a black piece on h2. Will add to the answer.  
  > **username_4**: @username_2: I don't completely agree with your additional analysis of what happened going back one move further. What you say is just one of two possibilities. Consider a position like the given position in the OP, with the addition of a White Knight on e3. Now 1.Nf1+ Kf1 2.Nh2+ Kxh2 gives the position we have, and the Black King moved twice. This is the only way Black King can have moved twice.  
  > **username_2**: @KnightoftheSquareTable: Indeed, will fix.  
  > **username_5**: -1. Kg1-h2 0.Ne3-f1+ does not work - while the knight is on e3, the black king could not have entered the first row (due to the then unrestrained rook). You will need some more intermediate moves to explain how the f the king got into the corner.  
  > **username_2**: @username_5 The king could have entered the first row from h2 or the knight could have captured a black piece on f1 (so that the check was blocked before that).  
  > **username_5**: I don't think that option 1 works (the king can only get to h2 via the first row, a vicious circle), but I have figured out option 2. :D  
  > **username_2**: @username_5 Yes there could be a vicious circle (knight moving between f1 and e3 and king between g1 and h2 any number of time), but before that at some point a black piece was captured on f1. Will add to the answer.  
  > **username_6**: There could be a black piece on f1 so it was Ne3xf1? Say it was a Re1 originally, then the king walks in over d3-e2-f1-g1, then the rook goes Re1-f1-e1-f1 while everything else is being put into place, then Kh2, Ne3xf1+, Kg1, Nh2, Kxh2. (Edit: oops - this isn't new).  
  
  ---
  
  ### Answer by username_5 on 2018-02-15. Score: 2
  
  Building on username_2's answer, here is a complete sequence of moves to show how the black king managed to trap himself in the corner in the first place:
  
  ```
  [FEN "8/8/8/8/2N1N3/3k2P1/3P2P1/2KRq3 b - - 0 1"]
  
  1... Ke2 2. Nc3+ Kf1 3. Ne4 Kg1 4. Ne3 Kh2 5. Nf2 Qg1 6. Nh1 Qf1 7. Nxf1+ Kg1 8. Nh2+ Kxh2
  
  ```
  
  Another possibility:
  
  ```
  [FEN "8/8/8/7q/2N1N3/3k2P1/3P2P1/2KRq3 b - - 0 1"]    
  
  1... Ke2 2. Nc3+ Kf1 3. Ne4 Kg1 4. Nf2 Kf1 5. Nh1 Kg1 6. Ne3 Qf1 7. Nxf1 Qh2 8. Nxh2+ Kxh2
  
  ```
  
  ---
  
  Third example by username_2 without blocking piece:
  
  ```
  [FEN "8/8/8/7q/2N1N3/3k2P1/3P2P1/2KR4 b - - 0 1"]
  
  1... Qh6 2. Kb2 Qh7 3. Ra1 Qh6 4. Kc1 Qh7 5. Nf2+
  Ke2 6. Nh1 Kf1 7. Ne3+ Kg1 8. Nf1 Qh6 9. Kb2
  Qh7 10. Rd1 Qh6 11. Kc1 Qh2 12. Nxh2+ Kxh2
  
  ```
  
  > **Comments:**
  > **username_2**: But all the moves before Nxf1+ are random and also the black queen could be another black piece, right?  
  > **username_2**: Also, this only shows one of the two possible solutions. The other has a black piece on h2 which gets captured by the knight.  
  > **username_5**: @username_2 Yes, there is more than one solution. Added another ;)  
  > **username_5**: @username_2 The moves before Nxf1+ show the safe paths of both the king but also the two knights (without (stale)mate) into the corner. And yes, the queens could also be rooks, obviously.  
  > **username_2**: I still think that you should make clear which moves are forced and which are optional. I believe in the first solution anything before Nxf1+ is optional to some extent. In the second solution you don't need a black blocking piece on the first row.  
  > **username_5**: @username_2 Yes I do need a blocking piece so that the black king can safely walk to g1 before the knight lands on f1. Distinguishing between forced and optional moves is not very productive, imo. Most of the "forced" moves are kinda optional anyways because pieces can be shuffled back and forth a few times for each move.  
  > **username_2**: No you don't need a blocking piece. See my edit above.  
  > **username_5**: @username_2 Ah, fair enough. The white king can block too. More waiting moves with the queen though.  
  > **username_2**: You don't even need to block with the king. You could also move the rook away somewhere. My point is that there are lots of possibilities and an answer/solution to such retro problem should IMO only include the moves that can be deduced with **certainty**. With certainty one can only say that the last move was king takes knight on h2. If you go back one move further you already end up with two options (which I can live with), there is not much point in figuring out all the different ways the king could have come to g1.  
  
  ---
  
  ### Answer by username_7 on 2018-04-28. Score: 1
  
  For the King to be on h2, it must have previously been on either h3 to g1. Being on h3 would have been impossible, since the g2-pawn has been there the entire game. So, the King must have been on g1.
  
  One could give a counterargument saying that Rd1 has been on the 1st rank for more than one move, since it appears stuck. However, this idea is refuted by the fact that White could have castled with 0-0-0.
  
  But then if White castled queenside, his King must have been on e1 the entire game.... which poses the problem of how Black's King got to g1 in the first place. I'm stuck at this point.
  
  EDIT: I didn't consider the possibility of White ALREADY castling, and then Black moves his King to e2. Maybe there's some White piece on the first rank that allows Black's King to move to g1 without being attacked by Rd1. Then, as username_2 pointed out, a move like Nf1-Nh2+ Kxh2 would give us the final position.
  
  
  ---
  
  