Programming with a Sporadic Shift Key
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
myFunc
is 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
n
has has to be generated by more fundamental means. Specifically we generate eachn
by counting a list, and then adding another item to that list. Therepeat with q in system info
allows us to do this 16 times, assystem info
always 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
text
and 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!
$
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.
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.