| Bytes | Lang | Time | Link |
|---|---|---|---|
| 027 | Nimrod / Nim v0.9.4 | 250804T043942Z | janAkali |
| 211 | Excel | 171129T133147Z | Wernisch |
| 211 | VB.NET | 141019T231051Z | Qwertiy |
| 020 | Whitespace 645 bytes | 141020T133737Z | Freyja |
| nan | I thought about my answer before getting to the '50 characters including only Enter | 141019T205957Z | Mike |
| nan | Applescript | 141017T185659Z | Digital |
| 220 | Python 2 | 141017T054724Z | Justin |
| nan | 141017T074652Z | edc65 | |
| 739 | CJam | 141017T103455Z | jimmy230 |
| 213 | CJam | 141017T062821Z | Optimize |
| 212 | CJam | 141017T055906Z | jimmy230 |
| 221 | Rant | 141017T070030Z | Berkin |
| 212 | PHP | 141017T062457Z | es1024 |
| 215 | Pyth | 141017T060012Z | Justin |
Nimrod / Nim v0.9.4, 2^-7
Nimrod (aka Nim before version 0.9.6) keywords and identifiers are completely case-insensitive. Shift-dependent characters: " , !
import strutils
echo capitalize "Dear Computer", tolower ", please stop giving me shift!"
Try it offline:
sudo apt install build-essential
git clone https://github.com/nim-lang/csources
git clone https://github.com/nim-lang/nim
cd csources
git checkout v0.9.4
sh build.sh --extraBuildArgs "-fpermissive" # fix for newer GCC versions
cp bin/nimrod ../nim/bin
cd ../nim
git checkout v0.9.4
bin/nimrod c --passc:"-fpermissive" --skipUserCfg --skipParentCfg koch
./koch boot -d:release --passc:"-fpermissive" --skipUserCfg --skipParentCfg
bin/nimrod c sporadic_shift.nim
./sporadic_shift
```
Excel, 2-11
=PROPER("Dear Computer, ")&LOWER("please stop giving me shift!")
Case of PROPER and LOWER don't matter.
Entering a formula starting with + automatically inserts required =.
So only (, ", ,, ), &, ! can break.
VB.NET, 2^-12 2^-11
2-12
Module All
Sub Main
Console.WriteLine StrConv("Dear Computer, ", vbTuesday) & "please stop giving me shift!".ToLower
End Sub
End Module
2-11
Imports System.Console
Module All
Sub Main
Write StrConv("Dear Computer, ", vbTuesday)
WriteLine "please stop giving me shift!".ToLower
End Sub
End Module
Whitespace (645 bytes, 2^0 probability)
Since this program only uses tabs, spaces and newlines (which are all unaffected by shifting), it gives a 100% success rate.
I thought about my answer before getting to the '50 characters including only Enter, Tab, Space' rule. So mine is not valid.
Seems having case insensitive programming languages is the key here. Alternatively, if you could use a Real standard QWERTY keyboard (including Caps Lock, the other Shift, Backspace, and the Numpad Period) there would only be 2 necessary 50% chances which would only result in 2 additional key presses per failure. My invalid answer for a C# Console Application pointing out actual key presses:
HoldShift(C CpsLockOn onsole)
NumPadPeriod
HoldShift(
CpsLockOff W CpsLockOn rite("
CpsLockOff D CpsLockOn ear space
CpsLockOff C CpsLockOn omputer
)
, (repeat with Backspace until correct)
HoldShift( please stop giving me shift!"))
; (repeat with Backspace until correct)
76 minimum presses with only 2 necessary 50% chances
Applescript, 20 (100%)
I believe I can claim a perfect score here:
- The Applescript Editor (my IDE) automatically converts all keywords to lower case upon compiling/running
- Furthermore, defined variable and handler names are case insensitive - For example if a handler
myFuncis defined, then the IDE will automatically convertMYFUNC,myfunc,MyFuNc, etc references tomyFunc - I have only used alphabetic characters, spaces and newlines, so I don't need to worry about shifted numbers and punctuation characters.
Here is is:
global f
on j at a
set end of a to j
end
on c at a
j at a
j at a
end
on k at a
repeat with q in system info
j at a
end
end
on w at a
set d to count a
j at a
return string id d
end
on z at a
set end of f to a
end
set h to space
set y to h as list
k at y
k at y
set x to w at y
c at y
c at y
c at y
c at y
c at y
set q to w at y
k at y
c at y
c at y
copy y to b
c at y
set s to w at y
set d to w at y
set f to d as list
k at b
k at b
set a to w at b
c at b
j at b
set e to w at b
set y to w at b
set g to w at b
set d to w at b
set i to w at b
c at b
set l to w at b
set m to w at b
set n to w at b
set o to w at b
set p to w at b
j at b
set r to w at b
z at e
z at a
z at r
z at h
z at s
set s to w at b
set t to w at b
set u to w at b
set v to w at b
z at o
z at m
z at p
z at u
z at t
z at e
z at r
z at q
z at h
z at p
z at l
z at e
z at a
z at s
z at e
z at h
z at s
z at t
z at o
z at p
z at h
z at g
z at i
z at v
z at i
z at n
z at g
z at h
z at m
z at e
z at h
z at s
z at d
z at i
z at y
z at t
z at x
f as text
Thanks to the help of @kernigh and @paradigmsort, this is now 1020 bytes, just squeaking in under the 1024 byte limit!
Explanation:
- The characters for output string are generated using
string id <n>, which returns the character corresponding to the ascii valuen - Because we are avoiding digits, each
nhas has to be generated by more fundamental means. Specifically we generate eachnby counting a list, and then adding another item to that list. Therepeat with q in system infoallows us to do this 16 times, assystem infoalways returns a 16-item list. - Using a similar technique, we add each character of the final string in turn to a list.
- Finally that last list is coerced to
textand printed.
Output:
Using the osascript interpreter, but the Applescript Editor works just as well:
$ # Interpret as-is:
$ osascript dearcase.scpt
Dear Computer, please stop giving me shift!
$
$ # Interpret all lower case:
$ tr A-Z a-z < dearcase.scpt | osascript
Dear Computer, please stop giving me shift!
$
$ # Interpret all upper case:
$ tr a-z A-Z < dearcase.scpt | osascript
Dear Computer, please stop giving me shift!
$
$ # Interpret random case for each letter:
$ while read; do for ((i=0;i<${#REPLY};i++)); do c="${REPLY:i:1}"; if ((RANDOM%2)); then printf "%s" "$(tr a-z A-Z <<< "$c")"; else printf "%s" "$(tr A-Z a-z <<< "$c")"; fi; done; echo; done < dearcase.scpt | osascript
Dear Computer, please stop giving me shift!
$
Python 2, 2-20 chance
print'S'+'top giving me shift!'.lower()
print, S, +, !, and .lower() must all be the correct version; that's 18 chars. The two quotes for the strings must also align, that makes two more powers of two.
For any of the top giving me shift, if it is converted to the capital version, we convert it to lowercase and it works properly.
Sadly, I can't make use of Python's nifty capitalize(), because that takes one more character.
VisualBasic.net 2^-18
Critical chars: .("DearC"+",!".())
Sub Main
console.write("Dear C"+"omputer, please stop giving me shift!".tolower())
End Sub
Tested in LINQPad, Language = "VB Program"
CJam, 2-9 chance, 739 bytes
"
(lines of space characters)
"N/2fb:c
base64:
IiAJICAgIAkgCQkgICAJICAKICAgCSAJCSAgIAkJCQkgCQoJCQkJIAkgIAkJIAkJICAJCiAJICAg
IAkgCQkgICAgCSAKICAgCSAJCSAgCSAgICAgIAogCQkJCSAJICAJCSAJIAkJCgkJCSAJICAJCSAJ
CSAJCQkKIAkgCQkgIAkgICAgIAkgCQoJIAkJICAJICAgIAkgICAgCgkgIAkJIAkJCQkgIAkJIAkK
CQkgCSAgCQkgCQkJIAkgIAogICAJIAkJICAgCQkJCSAJCiAJICAgIAkgCQkgICAgCSAKIAkJCQkg
CSAgCQkgCQkgIAogICAJIAkJICAJICAgICAgCgkgCQkgIAkgICAgCSAgICAKCSAgCSAgICAJIAkg
CQkgIAogICAJIAkJICAgCQkJCSAJCgkJCQkgCSAgCQkgCQkgIAkKICAgIAkgCQkgICAJCSAJCQog
ICAJIAkJICAgCQkJCSAJCiAgIAkgCQkgIAkgICAgICAKICAgIAkgCQkgICAJCSAJCQoJCSAJICAJ
CSAJCQkgCSAgCgkJCSAJICAJCSAJCSAJCQkKCSAJCSAgCSAgICAJICAgIAogICAJIAkJICAJICAg
ICAgCgkgCSAgCQkgCQkJIAkJCQkKICAJCSAJCQkJIAkgICAgCQogCQkgIAkgICAgCSAgCQkgCiAg
CQkgCQkJCSAJICAgIAkKICAJICAgIAkgCSAJCQkJIAoJIAkgIAkJIAkJCSAJCQkJCiAgIAkgCQkg
IAkgICAgICAKIAkgCQkgIAkgICAgIAkgCQogICAJIAkJICAgCQkJCSAJCiAgIAkgCQkgIAkgICAg
ICAKICAgIAkgCQkgICAJCSAJCQogCQkgCQkJCSAJICAJICAgCiAgCQkgCQkJCSAJICAgIAkKCQkg
CQkJCSAJICAJIAkJIAoJCSAJICAJCSAJCQkgCSAgCgkJIAkJCQkgCSAgCQkgIAkiTi8yZmI6Yw==
Based on the idea of Optimizer and Quincunx's answer.
CJam, 2-13 chance
As per the updated string (696 bytes).
"
"N/:,2/Kfb:c
Only ""N/:,2/Kfb:c are at risk right now.
Try it online here and since this text editor is eating up all the spaces, here is the gist with the correct code.
CJam, 2-7 2-12 chance
'D"ear Komputer, please stop giving me shift!"el4'Ct
It has similar idea as Quincunx's first answer, but in CJam.
Rant, 2-21
[caps:first][?[caps:word][?[caps:lower]Dear Computer][caps:lower], please stop giving me shift!]
A series of metapatterns and caps calls force proper formatting. Function names and arguments are case insensitive.
PHP, 2^-12
echo ucwords(strtolower('Dear Computer, ')).strtolower('please stop giving me shift!');
PHP being PHP, capitalization of echo, ucwords, and strtolower don't matter. The calls to ucwords and strtolower ensure that the case of the strings won't change the output.
Therefore, the only characters that can't be changed are ((,)).(!); (10 characters).
Each pair of quotes also has a 50% chance of being valid ('' and "" are valid, but '" and "' are not), therefore each adding another power of two.
Pyth, 2**-15
+"S"$"top giving me shift!".lower()
I can't seem to find Pyth's version of lower(), so I'll borrow from Python. The characters that can't be swapped are +"S"$, !, and .lower(), for a total of 14 chars. The quotes after the $ must match, adding another power of 2.