Skip to main content
7 of 8
combined my version with the discussion results on the group

Mumps, 91, 86, 82,79

r t i t?1A.1"." s a=$A(t),p=a>90*32+65 f i=1:1:25 { w *(a+i-p#26+p) w:t["." !}

Not such a modern language ;) I'm sure there's a bit of optimization space left..

Explanation:

r t 

read input

i t?1A.1"."

check if t matches the required input

s a=$A(t),p=a>90*32+65 f i=1:1:25 { w *(a+i-p#26+p) w:t["." !}

basic for loop through the alphabet. Note that mumps is strictly evaluating left to right. True=1, so you get 65 or 97 as a result for p, # is the modulo operator

tests:

USER>d ^golf
d.e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
a
b
c
 
USER>d ^golf
tuvwxyzabcdefghijklmnopqrs
USER>d ^golf
h.i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
a
b
c
d
e
f
g
 
USER>d ^golf
hallo
USER>

(you'll need a mumps runtime env, ie Caché to run this this)

edit: bold heading

edit: had a wrong solution, fixed now. Thanks to rtfs and Averroees for pointing this out