Here's how to solve this puzzle.
Promote your pawn to either a queen, a rook, or a chancellor. By promoting to a piece that moves orthogonally, Black is now in check. They have no moves, except for Nd8 or Nf8.
Capture the knight, regardless of whether it's on d8 or f8.