27
\$\begingroup\$

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;

QWERTY KEYBOARD LAYOUT

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)

!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!

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

2 Answers 2

42
\$\begingroup\$

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:

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

\$\endgroup\$
8
  • 2
    \$\begingroup\$ Using the asterisk was pretty clever! I'd never thought of that. \$\endgroup\$ Apr 23, 2015 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, 2015 at 21:23
  • 3
    \$\begingroup\$ I just knew CJam would have an answer... \$\endgroup\$ Apr 23, 2015 at 23:25
  • 9
    \$\begingroup\$ So one of the most future-proof languages in the world is apparently CJam. \$\endgroup\$
    – Fors
    Apr 24, 2015 at 12:41
  • 5
    \$\begingroup\$ Watch your finger when you hit the E, it looks like it might get taken into the abyss! \$\endgroup\$ Apr 24, 2015 at 17:30
3
\$\begingroup\$

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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