Skip to main content
switch from logic to arithmetic
Source Link
Julian Wolf
  • 1.2k
  • 6
  • 10

Haskell, 167 168168 126 bytes

f=fromEnum
r=replicate
a%b=fa?b=mod(f a-f b
a!b|a>=b=r(a%b-13)|8<9=r(26-b%a)13
c#x|elemc#x=r(c%xc?x)[0..13]||'<'++r(x%c-c?x)>14=c!x$'<'|8<9=x!c$'>''>'
s(c,s)x=(x,s++c#x++"*")
e(x:y)=x:snd(foldl s(x,[])y)

Now using xnor's arithmetic solution. Call with e str where str :: String is the string to be encoded.

Haskell, 167 168 bytes

f=fromEnum
r=replicate
a%b=f a-f b
a!b|a>=b=r(a%b)|8<9=r(26-b%a)
c#x|elem(c%x)[0..13]||(x%c)>14=c!x$'<'|8<9=x!c$'>'
s(c,s)x=(x,s++c#x++"*")
e(x:y)=x:snd(foldl s(x,[])y)

Call with e str where str :: String is the string to be encoded.

Haskell, 167 168 126 bytes

f=fromEnum
r=replicate
a?b=mod(f a-f b-13)26-13
c#x=r(c?x)'<'++r(-c?x)'>'
s(c,s)x=(x,s++c#x++"*")
e(x:y)=x:snd(foldl s(x,[])y)

Now using xnor's arithmetic solution. Call with e str where str :: String is the string to be encoded.

14 -> 13
Source Link
Julian Wolf
  • 1.2k
  • 6
  • 10

Haskell, 167167 168 bytes

f=fromEnum
r=replicate
a%b=f a-f b
a!b|a>b=rb|a>=b=r(a%b)|8<9=r(26-b%a)
c#x|elem(c%x)[0..14]||13]||(x%c)>14=c!x$'<'|8<9=x!c$'>'
s(c,s)x=(x,s++c#x++"*")
e(x:y)=x:snd(foldl s(x,[])y)

Call with e str where str :: String is the string to be encoded.

Haskell, 167 bytes

f=fromEnum
r=replicate
a%b=f a-f b
a!b|a>b=r(a%b)|8<9=r(26-b%a)
c#x|elem(c%x)[0..14]||(x%c)>14=c!x$'<'|8<9=x!c$'>'
s(c,s)x=(x,s++c#x++"*")
e(x:y)=x:snd(foldl s(x,[])y)

Call with e str where str :: String is the string to be encoded.

Haskell, 167 168 bytes

f=fromEnum
r=replicate
a%b=f a-f b
a!b|a>=b=r(a%b)|8<9=r(26-b%a)
c#x|elem(c%x)[0..13]||(x%c)>14=c!x$'<'|8<9=x!c$'>'
s(c,s)x=(x,s++c#x++"*")
e(x:y)=x:snd(foldl s(x,[])y)

Call with e str where str :: String is the string to be encoded.

Source Link
Julian Wolf
  • 1.2k
  • 6
  • 10

Haskell, 167 bytes

f=fromEnum
r=replicate
a%b=f a-f b
a!b|a>b=r(a%b)|8<9=r(26-b%a)
c#x|elem(c%x)[0..14]||(x%c)>14=c!x$'<'|8<9=x!c$'>'
s(c,s)x=(x,s++c#x++"*")
e(x:y)=x:snd(foldl s(x,[])y)

Call with e str where str :: String is the string to be encoded.