Quick! Escape the black hole!

28

3

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!

theonlygusti

Posted 2015-04-23T17:32:23.320

Reputation: 1 221

Downvote? I would much rather some feedback. – theonlygusti – 2015-04-23T17:39:06.257

13I'm downvoting this because it feels too constrained to have much creativity. – isaacg – 2015-04-23T17:44:22.503

@trichoplax Your right shift? – Mast – 2015-04-23T17:53:47.387

@trichoplax I think I've cleared all mentioned ambiguities, are there any more I should "iron out"? – theonlygusti – 2015-04-23T18:36:47.330

I've deleted my comments that you have now addressed, and this looks much better. Your link to my comment will no longer work since I've deleted the comment, so you might need to edit that back to normal text. – trichoplax – 2015-04-23T18:43:51.990

4Can we assume that using the python shell without print qualifies as STDOUT? – user80551 – 2015-04-23T20:02:59.637

I've never before seen a challenge here with such a small max character limit. 13 or fewer (more like 10-11 if you need shift and don't end with ) – Sparr – 2015-04-23T20:18:05.420

3What if my keyboard has a number pad? – mbomb007 – 2015-04-23T20:24:27.980

4This could be slightly better with arrow keys. – user80551 – 2015-04-23T20:27:29.283

1I don't see why people are still voting to close this question as unclear. How much ever restrictive/difficult be the challenge, its pretty clear after the recent edits. – Optimizer – 2015-04-23T20:48:13.780

6Is caps lock still effective if it's been pressed although the key has disappeared? – jscs – 2015-04-23T21:26:52.690

3@JoshCaswell I would assume so, since you don't need to hold it down. Test it on your keyboard. You'll need to find a black hole, first. But it's probably better to hold rt. shift instead... – mbomb007 – 2015-04-23T21:46:27.183

I give up if I can't use my keyboard's number pad. I haven't found another language that can do what CJam did in the same code length. – mbomb007 – 2015-04-23T21:54:58.287

I had the great idea to use GoLunar, but it's still too long... :( – mbomb007 – 2015-04-23T22:32:58.743

You know what they say about assumptions, @mbomb007. – jscs – 2015-04-24T07:45:42.487

Agreed with @isaacg, if the char limit tempo was slower this could make for an interesting challenge, but now it's getting a few answers at best instead. – Nit – 2015-04-24T14:12:49.323

What are the rules on derivative puzzles? I thought of a more relaxed challenge ("touch-typist's edition" - releasing modifier keys is free, and you can press one key with each hand [in any order] per cycle) that might get more responses. – Random832 – 2015-04-24T19:19:15.473

Answers

42

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

Optimizer

Posted 2015-04-23T17:32:23.320

Reputation: 25 836

2Using the asterisk was pretty clever! I'd never thought of that. – theonlygusti – 2015-04-23T18:37:19.523

2Well, 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 – 2015-04-23T21:23:23.773

3I just knew CJam would have an answer... – Jerry Jeremiah – 2015-04-23T23:25:13.220

9So one of the most future-proof languages in the world is apparently CJam. – Fors – 2015-04-24T12:41:24.547

5Watch your finger when you hit the E, it looks like it might get taken into the abyss! – Canadian Luke – 2015-04-24T17:30:23.643

1@CanadianLuke and 9 – Optimizer – 2015-04-24T17:38:27.347

Great graphical representation! Never heard of CJam, though. – vapcguy – 2015-04-25T01:03:58.683

@vapcguy You must be new. It's an esoteric programming language used only for code-golf AFAIK. The best/only way to learn it is to view existing code in answers on this site, or to view the home page: http://sourceforge.net/p/cjam/wiki/Home/

– mbomb007 – 2015-04-27T19:43:31.173

3

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.

kirbyfan64sos

Posted 2015-04-23T17:32:23.320

Reputation: 8 730

You forget that Enter is a stroke, too. 10 strokes. – vapcguy – 2015-04-27T20:26:01.330

1@vapcguy Right. Fixed. – kirbyfan64sos – 2015-04-27T20:31:13.333