It is the year 87,539,319 and solitary space-walking is now commonplace, many people travel into space by themselves, propelled by nothing but a jetpack on their backs, programming their course with a personal computer and keyboard as they go.

You are one such person; you were out on a lovely, peaceful spacewalk, when, all of a sudden, you were ensnared by the gravity of a black hole!

As you plummet towards this black hole, spiraling ever faster inwards, you realise your one chance of survival is to broadcast a distress message, and hope a nearby ship comes to rescue you.

So, you break out your keyboard, and begin typing away a program.

Your program can be in any language, and must print HELP! to stdout (your PC broadcasts all stdout far into the depths of space.)

However, as you are near a blackhole, your keyboard is slowly being ripped to shreds!

Assume you are using a QWERTY keyboard like the one below, and that the blackhole is to your left;


Remember, left and right shift are two different keys.

after every keypress, the left-most row of your keyboard (keys covered by left-most red line) is ripped off and flung into the black hole!

So, your first keypress could be any key on the keyboard, but from then onwards none of the leftmost Tab, Caps, Shift, Ctrl or ` keys may be used, at all. (r-shift and r-ctrl can still be used)

After the next keypress, the keys 1, Q, A,Z and Alt are flung into the abyss, and may not be used thereafter. After that, you lose Space, X, S, W, 2 and so forth.

Obviously, you want to complete your program as quickly as possible, so that rescue-time is increased; therefore, this is code-golf, and the shortest program in key presses wins!

Each answer should provide a list of keypresses, so, if my answer was this program (in the language squardibblyack)


a keylist could look like:

Shift!HELP release shift \.

length: 8

I'm worried this challenge might be too difficult, but I'd love to see the kinds of answers submitted!

  • 13
    \$\begingroup\$ I'm downvoting this because it feels too constrained to have much creativity. \$\endgroup\$ – isaacg Apr 23 '15 at 17:44
  • 4
    \$\begingroup\$ Can we assume that using the python shell without print qualifies as STDOUT? \$\endgroup\$ – user80551 Apr 23 '15 at 20:02
  • 3
    \$\begingroup\$ What if my keyboard has a number pad? \$\endgroup\$ – mbomb007 Apr 23 '15 at 20:24
  • 4
    \$\begingroup\$ This could be slightly better with arrow keys. \$\endgroup\$ – user80551 Apr 23 '15 at 20:27
  • 6
    \$\begingroup\$ Is caps lock still effective if it's been pressed although the key has disappeared? \$\endgroup\$ – Josh Caswell Apr 23 '15 at 21:26

CJam, 11 keystrokes

The code is


and the keylist is

Shift"HELP*") release shift 9-

and here is a demonstration of how it looks:

enter image description here

and here is how the code works:

"HELP*"              "This puts the string HELP* on stack";
       )             "This takes out the last character of the string and puts it
                      on the stack as a character";
        9-           "This simply reduces 9 from the ASCII code of * character
                      present on the stack which makes it an !";
                     "CJam automatically prints everything that is on stack";

Try the code here

  • 2
    \$\begingroup\$ Using the asterisk was pretty clever! I'd never thought of that. \$\endgroup\$ – theonlygusti Apr 23 '15 at 18:37
  • 2
    \$\begingroup\$ Well, I was unable to do this in GolfScript. It's a little too long. Converting from an integer to ascii is inefficient. "HELP*")9-[]+''+. I can't type the last four. \$\endgroup\$ – mbomb007 Apr 23 '15 at 21:23
  • 3
    \$\begingroup\$ I just knew CJam would have an answer... \$\endgroup\$ – Jerry Jeremiah Apr 23 '15 at 23:25
  • 9
    \$\begingroup\$ So one of the most future-proof languages in the world is apparently CJam. \$\endgroup\$ – Fors Apr 24 '15 at 12:41
  • 5
    \$\begingroup\$ Watch your finger when you hit the E, it looks like it might get taken into the abyss! \$\endgroup\$ – Canadian Luke REINSTATE MONICA Apr 24 '15 at 17:30

rs, 10 keystrokes (assumes the user is using Nano)

Or equivalent editor where Shift doesn't select text.

This isn't really a programming language, but if sed can be used on Code Golf, then rs can be used.

Right Shift ! Left E Left H Right L P Enter


It just replaces the empty string with "HELP!", effectively printing it to the screen. Roughly equivalent to the sed script:


The cool part is that rs automatically puts ^/ in front of a replacement pattern where the delimiter (/) is not found. Handy for indenting code.

  • \$\begingroup\$ You forget that Enter is a stroke, too. 10 strokes. \$\endgroup\$ – vapcguy Apr 27 '15 at 20:26
  • 1
    \$\begingroup\$ @vapcguy Right. Fixed. \$\endgroup\$ – kirbyfan64sos Apr 27 '15 at 20:31

I believe the quickest this could be done in any script is Random's 11 with Pyth, since any language is going to require some character, like "p" or a quote mark or asterisk or something, then the word HELP!, and that E is going to go quick, meaning extra key presses for moving the cursor back before E to put in H, like he found, then forwards again for L and P.

If you have anything that requires a command word, like disp or echo, you'd have to do a space first before it gets torn off, the Shift and !, then use the Home key to start your word, and arrow keys as Random described for HELP. But you'll be fumbling your way around until you're just sucked in or lose the keys you need too quickly to do any of those. There's only a max of 14 characters, and that's assuming your last one is \ or |. You need 10 just to do HELP!:


The defining " or * or P would get pressed just prior to the H. So 11 has got to be the quickest. Or 9 if we leave out the exclamation and capitalizing everything and don't have a symbol to type.

But no, me, being an internet historian in the year 87,539,319 and all, and being paranoid of aliens and the freak meteor shower, let alone black hole, I would not settle for that. Before I went out space-walking, I'd be prepared, with this article I would have found in my research to thank for that. I would load a text file that already has "HELP!" in it, and have a program that could write my coordinate position using the latest tracking satellite data we have into that file. That program I'd call "hlp.c", so it would go:

7 keystrokes:

c Home h l p . Enter

I realize I could make my file name shorter, but no one wants to broadcast their position by accident by typing H and Enter, especially if the program also alerts the authorities (a little like calling 911 when you don't have an emergency?) so let's go with a 3-letter filename, and we'll assume we have to still have file extensions with a . and minimum of 1 character. Also, naming it hlp instead of help means we avoid getting those nasty, built-in Help features when we're about to die in a black hole. I realize I could even possibly omit typing the .c by just doing h l p Enter, but this way I avoid those nasty Please supply file extension or Cannot find hlp errors when I'm about to get sucked into a black hole. "Garbage in, garbage out", after all, will still be a standard in the future.

So my graphic would look like:

enter image description here

And this would also be easy to remember, since the only "backwardsness" is typing c first. The rest is just like the file name.

  • 2
    \$\begingroup\$ First of all, if you're going with running a program (which already has the code in it) then it can be considered as a combination of several standard loopholes. Secondly, this is a code-golf, so you have to give the actual code, not an assumption that the code is already present in a file called hlp.c. Thirdly, you are supposed to provide the list of keystrokes for the program, not running the program. Fourthly, C programs ... \$\endgroup\$ – Optimizer Apr 25 '15 at 11:19
  • 1
    \$\begingroup\$ ... do not run like that. You need to first compile them and run them. So you will at least have to do help.exe (or help.out) in order to run the compiled code file. And lastly, if you are bending the rules and making use of the loopholes so much, why not simply have a file called h.c ? \$\endgroup\$ – Optimizer Apr 25 '15 at 11:21
  • \$\begingroup\$ The intent with a .c file was that it could be CSCRIPT, not actual C code that would require the compiler. Having h.c could mean when trying to type in the name of another file, with only 1 character in the name, that it is accidentally called instead of another file - I explained that already. Whatever code that was in the .c file, whether it was Console.Log("HELP!"), Console.WriteLine("HELP!"), etc., is largely irrelevant, especially since it was also going to include code to interface with satellites to get a coordinate fix - something I'm sure in the future will be open source. \$\endgroup\$ – vapcguy Apr 27 '15 at 19:55
  • \$\begingroup\$ My point with this post, too, was to indicate that having a file name, or something outside the bounds of the rules, was going to be the only way to beat 11 keystrokes, btw, since it takes 10 just for HELP!, as I mentioned before Kirby, and only less, like 9, if capitalization and using Shift didn't matter and we didn't have to have a character before or after HELP, such as with the exclamation point, or in Kirby's case, having to type a key character, like a p or * to initiate the program. \$\endgroup\$ – vapcguy Apr 27 '15 at 20:35
  • \$\begingroup\$ And help.exe and help.out would not work with the black hole's ripping apart of the keys. The e would be gone by the time exe came up, and the t is gone when trying to type out. You could type the t in out, first, then press Home, and type the HELP part, but if you could keep the extension to 1 character, why wouldn't you? \$\endgroup\$ – vapcguy Apr 27 '15 at 20:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.