Skip to main content
formatting -> 76
Source Link

Mumps, 91, 86, 82,7979,76

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

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

Mumps, 91, 86, 82,79,76

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

combined my version with the discussion results on the group
Source Link

Mumps, 91, 86, 8282,79

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

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

Explanation:

r *a,*bt 

read two characters, * makes read put the ascii code derictly in thereinput

i $c(a)t?1a,b#46#13=01A.1"."

check if a is a letter and b is . or entert 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:b=46t["." !}

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

Mumps, 91, 86, 82

r *a,*b i $c(a)?1a,b#46#13=0 s p=a>90*32+65 f i=1:1:25 {w *(a+i-p#26+p) w:b=46 !}

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

Explanation:

r *a,*b 

read two characters, * makes read put the ascii code derictly in there

i $c(a)?1a,b#46#13=0

check if a is a letter and b is . or enter

s p=a>90*32+65 f i=1:1:25 {w *(a+i-p#26+p) w:b=46 !}

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

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

replaced quit with if -- saved space after quit and is a shorter paired expression
Source Link

Mumps, 91, 8686, 82

r *a,*b q:'(i $c(a#32<27)&b#46#13a) ?1a,b#46#13=0 s p=a>90*32+65 f i=1:1:25 { w *(a+i-p#26+p) w:b=46 !}

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

Explanation:

r *a,*b 

read two characters, * makes read put the ascii code derictly in there

q:'(i $c(a#32<27)&b#46#13a)?1a,b#46#13=0

check if a is a letter and b is . or enter

s p=a>90*32+65 f i=1:1:25 { w *(a+i-p#26+p) w:b=46 !}

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

Mumps, 91, 86

r *a,*b q:'((a#32<27)&b#46#13)  s p=a>90*32+65 f i=1:1:25 { w *(a+i-p#26+p) w:b=46 !}

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

Explanation:

r *a,*b 

read two characters, * makes read put the ascii code derictly in there

q:'((a#32<27)&b#46#13)

check if a is a letter and b is . or enter

s p=a>90*32+65 f i=1:1:25 { w *(a+i-p#26+p) w:b=46 !}

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

Mumps, 91, 86, 82

r *a,*b i $c(a)?1a,b#46#13=0 s p=a>90*32+65 f i=1:1:25 {w *(a+i-p#26+p) w:b=46 !}

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

Explanation:

r *a,*b 

read two characters, * makes read put the ascii code derictly in there

i $c(a)?1a,b#46#13=0

check if a is a letter and b is . or enter

s p=a>90*32+65 f i=1:1:25 {w *(a+i-p#26+p) w:b=46 !}

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

shorter version
Source Link
Loading
fixed error in solution
Source Link
Loading
new version 80->71
Source Link
Loading
put console output in codeblock
Source Link
Loading
Source Link
Loading