39
7
There's something wrong with your keyboard. The Shift key has a mind of its own. Every time you type a character you have no idea whether it will come out shifted or not (though it is 50-50). Besides the standard character keys, nothing on the keyboard is functional. There is no mouse or other means of input.
Somehow you know the only way to fix things is to write a program that outputs Dear Computer, please stop giving me shift!
to stdout. Luckily your IDE is open and you are capable of running a program, but of course as you type it you won't know which characters will be shifted.
What sequence of key-presses would you use to write a program that has the best possible chance of working on the first try?
Details
You are using a standard QWERTY keyboard, so there are 50 character keys you can press.
Unshifted versions (47 only):
`1234567890-=qwertyuiop[]\asdfghjkl;'zxcvbnm,./
Shifted versions (47 only):
~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:"ZXCVBNM<>?
The last 3 keys are Enter, Tab, and Space, which are the same shifted and unshifted.
A sequence of N of these characters has 2N - (whitespace char count) ways it might have been output if you had typed them with your faulty keyboard. For example, typing A Space m might have yielded
a m
or A m
or a M
or A M
.
Write a program these characters and look at all of its 2N - (whitespace char count) possible shift combinations. The more combinations that output Dear Computer, please stop giving me shift!
the better. Your score is the number of working combinations (valid programs) divided by the total number of combinations. The highest score wins.
Notes
- For valid programs, printing precisely
Dear Computer, please stop giving me shift!
and nothing else to stdout should be the only side effect. - Valid programs should not take input.
- Invalid programs can do anything whatsoever.
- Comments may be used anywhere.
- Whitespace answers cannot win because getting a 100% score is (relatively) trivial. You may still submit a Whitespace solution for fun.
- Your program must be at most 1024 characters long.
Update: Changed Stop giving me shift!
to Dear Computer, please stop giving me shift!
to allow for more complex answers. Existing answers may stay the way they are if desired.
Why's the 1024-character restriction? – John Dvorak – 2014-10-17T05:20:52.753
@JanDvorak Without a limit there might be ways to make the limit of valid programs approach 100% as the size of the program increases. (Though that would be pretty cool.) – Calvin's Hobbies – 2014-10-17T05:24:55.850
I can't think of any way to improve the baseline score of 2^-(18 + whatever the language needs) – John Dvorak – 2014-10-17T05:32:18.967
Please ping me once there is a better answer than mine – John Dvorak – 2014-10-17T05:34:00.750
@JanDvorak Without the restriction, you could do something like
exec(min(["code","code","code",...]))
, with a ginormous number of copies of your code to run a lower-cased version of it basically guaranteed. – xnor – 2014-10-17T06:00:46.5802+1, it's a great challenge, but I wish you'd given us a longer output string. I've thought of several clever tricks, but all of them take more than 18 characters in all the languages I know. – Nathaniel – 2014-10-17T06:04:17.757
@Nathaniel I was just wishing that too,. It's only been an hour, I may change it. – Calvin's Hobbies – 2014-10-17T06:06:57.870
2@Calvin'sHobbies but... what about the current answers? – John Dvorak – 2014-10-17T06:13:01.420
@xnor the problem with your suggestion is that each pair quotes is a 2^-1 to your score and so are the commas inbetween. Unless you do something like
.words
– John Dvorak – 2014-10-17T06:15:40.107I have changed the phrase. Existing answers can stay, though not a ton may need to change in them. Apologies for rule change. (@Nathaniel) – Calvin's Hobbies – 2014-10-17T06:16:02.383
@Calvin'sHobbies Now the score becomes a non standard as the previous string will always result in a lower score. Can you either switch back to older string or mandate the use of new one ? – Optimizer – 2014-10-17T06:52:08.740
@Optimizer Sorry but it would be unfair to the original answers to force the change. All new answers must use the new string through, and it may be possible to beat the best old answer. – Calvin's Hobbies – 2014-10-17T07:03:16.773
1@Calvin'sHobbies It's not! And the 1024 limitation prevents that very well too. given all this, I am voting for this to close as unclear what you are asking. Please do not change spec which gives disadvantage to most of the answers – Optimizer – 2014-10-17T07:05:31.250
1@Calvin'sHobbies Too bad there's the 1024 char limit. I'm going to need to rethink my answer... – Justin – 2014-10-17T07:05:32.507
@Optimizer I have removed the 2^-7 one in the answer. So there isn't much trouble now. – jimmy23013 – 2014-10-17T08:14:53.820
@user23013 There are other answers based on the previous string too. – Optimizer – 2014-10-17T09:23:37.133
1@Optimizer At least they won't win. – jimmy23013 – 2014-10-17T09:31:50.893
I'm assuming you're not allowed or able to hold down the other shift key to force everything shifted? Or would doing so give you a 75% chance of being shifted and 25% of unshifted if both of your shift keys act identical? – WOUNDEDStevenJones – 2014-10-17T21:15:18.673
@WOUNDEDStevenJones No. Assume pressing either shift does nothing. The computer just thinks shift is being pressed randomly. – Calvin's Hobbies – 2014-10-17T21:22:15.187
1For once in my life, knowledge of VB is more useful than knowledge of C++. – Pharap – 2014-10-18T10:24:31.443
A perfect time to use WhiteSpace?
– recursion.ninja – 2014-10-20T01:03:49.227@awashburn That's not allowed (for winning). See rules. – Calvin's Hobbies – 2014-10-20T01:23:58.033