Skip to main content
edited body
Source Link
gxtaillon
  • 607
  • 4
  • 14

Haskell - 265 267 bytes (no IO)

p=g(1,0,1,1,3,3)where g(q,r,t,k,n,l)=if 4*q+r-t<n*t then n:g(10*q,10*(r-n*t),t,k,div(10*(3*q+r))t-10*n,l) else g(q*k,(2*q+r)*l,t*l,k+1,div(q*(7*k+2)+r*l)(t*l),l+2)
e i s=zipWith(\k c->toEnum$fromIntegral k+fromEnum c::Char)(take(length s)$drop(fromIntegral$i-1)p)s

p is a golfed version of the algorithm that can be found at http://rosettacode.org/wiki/Pi#Haskell

e is the encoding function :

λ> e 2 "house"
"isvxn"

It does not loop around if an index is outside of the lowercase alphabet. This means that some other characters can slip in the encoded string :

"Sfufv#Kork(mq}nns j{i&sv&xitmujtu&vey|h{xljej|35.)(\"%(\"\"&\" %\"\"$()$ ''\"&'!)$'(\"&($(\"& !$'&)]hrs\"ow olih7$Tdkhnsj ns&qpdlw}oplwmxbipn#o{ur!vhbp\"mitj/"

Unfortunately, it takes several seconds with offsets greater than 10 000 to compute the output. Fortunately, when using the same offset multiple times, the digits only have to be computed the first time.

Bonus - Decoding

d i s=zipWith(\k c->toEnum$fromEnum c-fromIntegral k::Char)(take(length s)$drop(i-1)p)s

Again if we test with isvxn :

λ> d 2 "isvsn""isvxn"
"house"

Haskell - 265 267 bytes (no IO)

p=g(1,0,1,1,3,3)where g(q,r,t,k,n,l)=if 4*q+r-t<n*t then n:g(10*q,10*(r-n*t),t,k,div(10*(3*q+r))t-10*n,l) else g(q*k,(2*q+r)*l,t*l,k+1,div(q*(7*k+2)+r*l)(t*l),l+2)
e i s=zipWith(\k c->toEnum$fromIntegral k+fromEnum c::Char)(take(length s)$drop(fromIntegral$i-1)p)s

p is a golfed version of the algorithm that can be found at http://rosettacode.org/wiki/Pi#Haskell

e is the encoding function :

λ> e 2 "house"
"isvxn"

It does not loop around if an index is outside of the lowercase alphabet. This means that some other characters can slip in the encoded string :

"Sfufv#Kork(mq}nns j{i&sv&xitmujtu&vey|h{xljej|35.)(\"%(\"\"&\" %\"\"$()$ ''\"&'!)$'(\"&($(\"& !$'&)]hrs\"ow olih7$Tdkhnsj ns&qpdlw}oplwmxbipn#o{ur!vhbp\"mitj/"

Unfortunately, it takes several seconds with offsets greater than 10 000 to compute the output.

Bonus - Decoding

d i s=zipWith(\k c->toEnum$fromEnum c-fromIntegral k::Char)(take(length s)$drop(i-1)p)s

Again if we test with isvxn :

λ> d 2 "isvsn"
"house"

Haskell - 265 267 bytes (no IO)

p=g(1,0,1,1,3,3)where g(q,r,t,k,n,l)=if 4*q+r-t<n*t then n:g(10*q,10*(r-n*t),t,k,div(10*(3*q+r))t-10*n,l) else g(q*k,(2*q+r)*l,t*l,k+1,div(q*(7*k+2)+r*l)(t*l),l+2)
e i s=zipWith(\k c->toEnum$fromIntegral k+fromEnum c::Char)(take(length s)$drop(fromIntegral$i-1)p)s

p is a golfed version of the algorithm that can be found at http://rosettacode.org/wiki/Pi#Haskell

e is the encoding function :

λ> e 2 "house"
"isvxn"

It does not loop around if an index is outside of the lowercase alphabet. This means that some other characters can slip in the encoded string :

"Sfufv#Kork(mq}nns j{i&sv&xitmujtu&vey|h{xljej|35.)(\"%(\"\"&\" %\"\"$()$ ''\"&'!)$'(\"&($(\"& !$'&)]hrs\"ow olih7$Tdkhnsj ns&qpdlw}oplwmxbipn#o{ur!vhbp\"mitj/"

Unfortunately, it takes several seconds with offsets greater than 10 000 to compute the output. Fortunately, when using the same offset multiple times, the digits only have to be computed the first time.

Bonus - Decoding

d i s=zipWith(\k c->toEnum$fromEnum c-fromIntegral k::Char)(take(length s)$drop(i-1)p)s

Again if we test with isvxn :

λ> d 2 "isvxn"
"house"
added 13 characters in body
Source Link
gxtaillon
  • 607
  • 4
  • 14

Haskell - 267265 267 bytes (no IO)

p=g(1,0,1,1,3,3)where g(q,r,t,k,n,l)=if 4*q+r-t<n*t then n:g(10*q,10*(r-n*t),t,k,div(10*(3*q+r))t-10*n,l) else g(q*k,(2*q+r)*l,t*l,k+1,div(q*(7*k+2)+r*l)(t*l),l+2)
e i s=zipWith(\k c->toEnum$(fromIntegral>toEnum$fromIntegral k)+fromEnumk+fromEnum c::Char)(take(length s)$drop(fromIntegral$i-1)p)s

p is a golfed version of the algorithm that can be found at http://rosettacode.org/wiki/Pi#Haskell

e is the encoding function :

λ> e 2 "house"
"isvxn"

It does not loop around if an index is outside of the lowercase alphabet. This means that some other characters can slip in the encoded string :

"Sfufv#Kork(mq}nns j{i&sv&xitmujtu&vey|h{xljej|35.)(\"%(\"\"&\" %\"\"$()$ ''\"&'!)$'(\"&($(\"& !$'&)]hrs\"ow olih7$Tdkhnsj ns&qpdlw}oplwmxbipn#o{ur!vhbp\"mitj/"

Unfortunately, it takes several seconds with offsets greater than 10 000 to compute the output.

Bonus - Decoding

d i s=zipWith(\k c->toEnum$fromEnum c-fromIntegral k::Char)(take(length s)$drop(i-1)p)s

Again if we test with isvxn :

λ> d 2 "isvsn"
"house"

Haskell - 267 bytes (no IO)

p=g(1,0,1,1,3,3)where g(q,r,t,k,n,l)=if 4*q+r-t<n*t then n:g(10*q,10*(r-n*t),t,k,div(10*(3*q+r))t-10*n,l) else g(q*k,(2*q+r)*l,t*l,k+1,div(q*(7*k+2)+r*l)(t*l),l+2)
e i s=zipWith(\k c->toEnum$(fromIntegral k)+fromEnum c::Char)(take(length s)$drop(fromIntegral$i-1)p)s

p is a golfed version of the algorithm that can be found at http://rosettacode.org/wiki/Pi#Haskell

e is the encoding function :

λ> e 2 "house"
"isvxn"

It does not loop around if an index is outside of the lowercase alphabet. This means that some other characters can slip in the encoded string :

"Sfufv#Kork(mq}nns j{i&sv&xitmujtu&vey|h{xljej|35.)(\"%(\"\"&\" %\"\"$()$ ''\"&'!)$'(\"&($(\"& !$'&)]hrs\"ow olih7$Tdkhnsj ns&qpdlw}oplwmxbipn#o{ur!vhbp\"mitj/"

Unfortunately, it takes several seconds with offsets greater than 10 000 to compute the output.

Bonus - Decoding

d i s=zipWith(\k c->toEnum$fromEnum c-fromIntegral k::Char)(take(length s)$drop(i-1)p)s

Again if we test with isvxn :

λ> d 2 "isvsn"
"house"

Haskell - 265 267 bytes (no IO)

p=g(1,0,1,1,3,3)where g(q,r,t,k,n,l)=if 4*q+r-t<n*t then n:g(10*q,10*(r-n*t),t,k,div(10*(3*q+r))t-10*n,l) else g(q*k,(2*q+r)*l,t*l,k+1,div(q*(7*k+2)+r*l)(t*l),l+2)
e i s=zipWith(\k c->toEnum$fromIntegral k+fromEnum c::Char)(take(length s)$drop(fromIntegral$i-1)p)s

p is a golfed version of the algorithm that can be found at http://rosettacode.org/wiki/Pi#Haskell

e is the encoding function :

λ> e 2 "house"
"isvxn"

It does not loop around if an index is outside of the lowercase alphabet. This means that some other characters can slip in the encoded string :

"Sfufv#Kork(mq}nns j{i&sv&xitmujtu&vey|h{xljej|35.)(\"%(\"\"&\" %\"\"$()$ ''\"&'!)$'(\"&($(\"& !$'&)]hrs\"ow olih7$Tdkhnsj ns&qpdlw}oplwmxbipn#o{ur!vhbp\"mitj/"

Unfortunately, it takes several seconds with offsets greater than 10 000 to compute the output.

Bonus - Decoding

d i s=zipWith(\k c->toEnum$fromEnum c-fromIntegral k::Char)(take(length s)$drop(i-1)p)s

Again if we test with isvxn :

λ> d 2 "isvsn"
"house"
added 99 characters in body
Source Link
gxtaillon
  • 607
  • 4
  • 14

Haskell - 267 bytes (no IO)

p=g(1,0,1,1,3,3)where g(q,r,t,k,n,l)=if 4*q+r-t<n*t then n:g(10*q,10*(r-n*t),t,k,div(10*(3*q+r))t-10*n,l) else g(q*k,(2*q+r)*l,t*l,k+1,div(q*(7*k+2)+r*l)(t*l),l+2)
e i s=zipWith(\k c->toEnum$(fromIntegral k)+fromEnum c::Char)(take(length s)$drop(fromIntegral$i-1)p)s

p is a golfed version of the algorithm that can be found at http://rosettacode.org/wiki/Pi#Haskell

e is the encoding function :

λ> e 2 "house"
"isvxn"

It does not loop around if an index is outside of the lowercase alphabet. This means that some other characters can slip in the encoded string :

"Sfufv#Kork(mq}nns j{i&sv&xitmujtu&vey|h{xljej|35.)(\"%(\"\"&\" %\"\"$()$ ''\"&'!)$'(\"&($(\"& !$'&)]hrs\"ow olih7$Tdkhnsj ns&qpdlw}oplwmxbipn#o{ur!vhbp\"mitj/"

Unfortunately, it takes several seconds with offsets greater than 10 000 to compute the output.

Bonus - Decoding

d i s=zipWith(\k c->toEnum$fromEnum c-fromIntegral k::Char)(take(length s)$drop(i-1)p)s

Again if we test with isvxn :

λ> d 2 "isvsn"
"house"

Haskell - 267 bytes (no IO)

p=g(1,0,1,1,3,3)where g(q,r,t,k,n,l)=if 4*q+r-t<n*t then n:g(10*q,10*(r-n*t),t,k,div(10*(3*q+r))t-10*n,l) else g(q*k,(2*q+r)*l,t*l,k+1,div(q*(7*k+2)+r*l)(t*l),l+2)
e i s=zipWith(\k c->toEnum$(fromIntegral k)+fromEnum c::Char)(take(length s)$drop(fromIntegral$i-1)p)s

p is a golfed version of the algorithm that can be found at http://rosettacode.org/wiki/Pi#Haskell

e is the encoding function :

λ> e 2 "house"
"isvxn"

It does not loop around if an index is outside of the lowercase alphabet. This means that some other characters can slip in the encoded string :

"Sfufv#Kork(mq}nns j{i&sv&xitmujtu&vey|h{xljej|35.)(\"%(\"\"&\" %\"\"$()$ ''\"&'!)$'(\"&($(\"& !$'&)]hrs\"ow olih7$Tdkhnsj ns&qpdlw}oplwmxbipn#o{ur!vhbp\"mitj/"

Unfortunately, it takes several seconds with offsets greater than 10 000 to compute the output.

Haskell - 267 bytes (no IO)

p=g(1,0,1,1,3,3)where g(q,r,t,k,n,l)=if 4*q+r-t<n*t then n:g(10*q,10*(r-n*t),t,k,div(10*(3*q+r))t-10*n,l) else g(q*k,(2*q+r)*l,t*l,k+1,div(q*(7*k+2)+r*l)(t*l),l+2)
e i s=zipWith(\k c->toEnum$(fromIntegral k)+fromEnum c::Char)(take(length s)$drop(fromIntegral$i-1)p)s

p is a golfed version of the algorithm that can be found at http://rosettacode.org/wiki/Pi#Haskell

e is the encoding function :

λ> e 2 "house"
"isvxn"

It does not loop around if an index is outside of the lowercase alphabet. This means that some other characters can slip in the encoded string :

"Sfufv#Kork(mq}nns j{i&sv&xitmujtu&vey|h{xljej|35.)(\"%(\"\"&\" %\"\"$()$ ''\"&'!)$'(\"&($(\"& !$'&)]hrs\"ow olih7$Tdkhnsj ns&qpdlw}oplwmxbipn#o{ur!vhbp\"mitj/"

Unfortunately, it takes several seconds with offsets greater than 10 000 to compute the output.

Bonus - Decoding

d i s=zipWith(\k c->toEnum$fromEnum c-fromIntegral k::Char)(take(length s)$drop(i-1)p)s

Again if we test with isvxn :

λ> d 2 "isvsn"
"house"
added 99 characters in body
Source Link
gxtaillon
  • 607
  • 4
  • 14
Loading
Source Link
gxtaillon
  • 607
  • 4
  • 14
Loading