# Quick! Escape the black hole!

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!

!HELP\.


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!

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

# CJam, 11 keystrokes

The code is

"HELP*")9-


and the keylist is

Shift"HELP*") release shift 9-

and here is a demonstration of how it looks:

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

• Using the asterisk was pretty clever! I'd never thought of that. – theonlygusti Apr 23 '15 at 18:37
• 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. – mbomb007 Apr 23 '15 at 21:23
• I just knew CJam would have an answer... – Jerry Jeremiah Apr 23 '15 at 23:25
• So one of the most future-proof languages in the world is apparently CJam. – Fors Apr 24 '15 at 12:41
• Watch your finger when you hit the E, it looks like it might get taken into the abyss! – Canadian Luke 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

HELP!


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

s/^/HELP!/


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

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