The Kobayashi Maru is a 1989 Star Trek science fiction novel by Julia Ecklar which centers around several characters from The Original Series marooned in space on a disabled shuttlecraft.
Its title comes from the unwinnable Starfleet Academy training scenario first introduced in the 1982 movie Star Trek II: The Wrath of Khan.
In a system with 47 planets and unstable gravitic anomalies, the transporter is not usable, so Kirk and crew take the shuttle Halley to Hohweyn VII.
Kirk explains how, as a young cadet, he spent countless nights studying ships and battles in a futile attempt to outthink the computer managing the scenario, until he finally realized that the only way to win was to "change the rules".
Chekov chooses to sacrifice his ship and destroy the Klingon vessels while evacuating his crew but is criticized for failing to account for the fact that the intense amount of space debris would make any rescue attempt impossible.
As Sulu is wheeled away by McCoy to the sickbay and Scott sets about salvaging the Halley, Kirk brings up the Kobayashi Maru while Spock is helping him walk to the bridge.