g | x | w | all
Bytes Lang Time Link
077Swift 6250705T145657ZmacOSist
015Pip250703T205055ZDLosc
009Vyxal 3250702T081337ZThemooni
011Uiua240802T005200ZjanMakos
184Setanta240802T001931Zbb94
033Raku Perl 6 rakudo240802T001229Zbb94
012UiuaSBCS240801T204331ZEurope20
029Pyth220307T205200Zsinvec
051Haskell200617T155630ZLaikoni
1716x8616 machine code200603T214342Z640KB
055Haskell200605T182830Zcole
060Java OpenJDK 8200604T025910Zbranboye
068Wolfram Language200604T221217ZDanTheMa
009Stax200604T183725Zrecursiv
022APL Dyalog Unicode200603T082529ZRGS
025Ly200604T111945ZLyricLy
046C gcc200603T111218ZNoodle9
100TSQL200603T091237Zt-clause
068Erlang escript200603T231652Zuser9206
057R200603T103657ZDominic
032Perl 5 p200603T083718ZNahuel F
048C gcc200603T100231ZAsone Tu
009Jelly200603T120454ZJonathan
00905AB1E200603T082648ZKevin Cr
054Python 3.8200603T084544Zovs
020Befunge98 FBBI200603T115157Zovs
019K oK200603T113140ZGalen Iv
019Keg200603T114451Zlyxal
025Befunge93200603T103120ZAbigail
042JavaScript Node.js200603T102522ZArnauld
019Retina 0.8.2200603T101326ZNeil
009Charcoal200603T095637ZNeil
077JavaScript200603T093041Zdarrylye
022J200603T090836ZBubbler
022APL Dyalog Extended200603T090436ZAdá
042Ruby200603T085844ZAsone Tu
021APL dzaima/APL200603T085400ZBubbler

Swift 6, 77 bytes

{($0+"",""+$0.utf8.enumerated().map{.init(.init(($0+Int($1)-32)%95+32)!)}).1}

Try it on SwiftFiddle!

Pip, 15 bytes

(PA_+A B-32MEa)

Attempt This Online!

Explanation

(PA_+A B-32MEa)
             a   ; Command-line argument
           ME    ; Map-enumerate (_ is index, B is character):
   _             ;   Index
    +A B         ;   Plus ASCII value of character
        -32      ;   Minus 32
(PA           )  ; Use those values as indices into PA, a builtin for printable ASCII
                 ; Indexing is cyclical, which takes care of the wraparound
                 ; Concatenate that list of characters and autoprint (implicit)

Alternate solutions

Indexing into PA instead of using the ASCII code yields a couple of less-straightforward solutions that are also 15 bytes:

(PAaME_+YPA@?B)
(PA$+GMEPA@?^a)

Vyxal 3, 9 bytes

O③-:ƶ+kPi

-5 bytes by pacman256

Vyxal It Online!

O③-:ƶ+kPi­⁡​‎‎⁡⁠⁡‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁢‏⁠‎⁡⁠⁣‏‏​⁡⁠⁡‌⁣​‎‎⁡⁠⁤‏⁠‎⁡⁠⁢⁡‏⁠‎⁡⁠⁢⁢‏‏​⁡⁠⁡‌⁤​‎‎⁡⁠⁢⁣‏⁠‎⁡⁠⁢⁤‏⁠‎⁡⁠⁣⁡‏‏​⁡⁠⁡‌­
O          # ‎⁡convert ascii to values
 ③-        # ‎⁢substract 32
   :ƶ+     # ‎⁣add each value's position to itself
      kPi  # ‎⁤index that value into printable ascii (wraps)
💎

Created with the help of Luminespire.

<script type="vyxal3">
O③-:ƶ+kPi
</script>
<script>
    args=[["Hello, world!"],["The random guy"],["zzzzzzzzz"]]
</script>
<script src="https://themoonisacheese.github.io/snippeterpreter/snippet.js" type="module"/>

Uiua, 11 bytes

⍜⊙-◿95@ +°⊏

Try it out!

Explanation:

⍜⊙-◿95@ +°⊏
         °⊏ # list of the indices of each char
        +   # add to each char its index
 ⊙-   @     # find the ascii difference between each char and SPACE
   ◿95      # Modulus 95
⍜           # turn back into chars

Setanta, 184 bytes

Setanta doesn’t have a chr or ord so I have to include the entire set of printable ASCII characters.

gniomh(s){A:=go_liosta@" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"()t:=""le i idir(0,fad@s)t+=A[(aimsigh@A(s[i])+i)%95]toradh t}

try-setanta.ie link

Raku (Perl 6) (rakudo), 33 bytes

{chrs ((.ords Z+-32..*)X%95)X+32}

Attempt This Online!

UiuaSBCS, 12 bytes

+@ ◿95-@ +°⊏

Try it here!

Explanation

+@ ◿95-@ +°⊏
          °⊏ create an array of all whole numbers less than the length of the string
         +   for each pair, shift the character by the number
      -@     convert the characters to codepoints from the space character
   ◿95       modulo 95
+@           convert them back into characters

Pyth, 29 bytes

VlQ=+Y-C@QN32;s.eC+%+bk95 32Y

Try it online!

Haskell, 52 51 bytes

zipWith(%)[-32..]
n%c=toEnum$32+mod(fromEnum c+n)95

Try it online!


Haskell, 52 bytes

zipWith(%)[0..]
n%c=snd(span(<c)$cycle[' '..'~'])!!n

Try it online!

Explanation

x86-16 machine code, IBM PC DOS, 17 16 bytes

Binary:

Build STL.COM using xxd -r:

00000000: b120 b408 cd21 2ac1 d45f 0420 cd29 e0f2  . ...!*.._. .)..

Listing:

B1 20       MOV  CL, 32         ; set up offset / position counter 
        CLOOP: 
B4 08       MOV  AH, 8          ; use DOS API get char from STDIN function 
CD 21       INT  21H            ; read input char into AL 
2A C1       SUB  AL, CL         ; subtract offset 
D4 5F       AAM  95             ; AL = AL % 95 
04 20       ADD  AL, 32         ; restore ASCII offset 
CD 29       INT  29H            ; output AL to console 
E0 F2       LOOPNZ CLOOP        ; keep looping until break, decrement CL

Standalone IBM PC DOS executable program. Input via STDIN, output to console.

Runtime:

enter image description here

Haskell, 55 bytes

g '~'=' '
g c=succ c
i!c=iterate g c!!i
zipWith(!)[0..]

Try it online!

The TIO link has f=, but that doesn't contribute to the byte count because I defined it point-free. It's mostly there so that the code compiles.

I didn't play around much with using a point-free definition instead of !, so that might be a place where some bytes can be shaved off. I just figured that the parens and dots would add up. I also want to get rid of the call to iterate, but I'm not sure how. I want something like mtimes...

Haskell + -XParallelListComp, 55 bytes

g '~'=' '
g c=succ c
f s=[iterate g c!!i|c<-s|i<-[0..]]

Try it online!

Unfortunately this isn't any shorter, but I thought it was a cool usage of a pragma. It seems most of the time that pragmas aren't too helpful in golfing.

Explanation

-- g gives the successor of each character according to the specification
g :: Char -> Char
-- the successor of '~' is ' ' (wrap around)
g '~'=' '
-- all other characters have their normal successor
g c=succ c

-- (!) is an infix function that enciphers a character, given an int
(!) :: Int -> Char -> Char
-- iterate produces an infinite list of 'g' applied to 'c' repeatedly,
-- and '!!' indexes into that list at index 'i'. This has the effect
-- of applying 'g' to 'c' 'i' times.
i!c=iterate g c!!i

-- Point-free definition that applies '!' to each character of the input along with its index
zipWith(!)[0..]

Java (OpenJDK 8), 80 60 bytes

s->{int i=0;for(char n:s)s[i]+=i-(n+i++>126?95:0);return s;}

Try it online!

Thanks for help from Kevin Cruijssen

Wolfram Language, 68 bytes

FromCharacterCode@Mod[#&~Array~Length@#+#-1,95,32]&@*ToCharacterCode

Uses a little function composition to make it shorter, but other than that, does pretty much what it says on the tin. Converts the string to character codes, adds the proper offset to each, wraps around if needed using Mod (there's an optional argument for offset that I use here), then converts back to a string.

Stax, 9 bytes

éñÇöo♣j0♦

Run and debug it

APL (Dyalog Unicode), 28 24 22 bytes SBCS

-4 bytes thanks to @Adám; -2 bytes thanks to @ngn;

Monadic function expecting a string:

⎕ucs 32+95|⎕ucs-32-⍳∘≢

Try it online! Assumes ⎕IO←0. How the 24-byter works:

32(⎕ucs⊣+95|⊢--∘⍳∘≢)⎕ucs  ⍝ monadic function taking a character vector on the right
                     ⎕ucs  ⍝ convert to unicode code points
32(                 )      ⍝ and then evaluate the expression with 32 as left argument and the code points as right arg
               -∘⍳∘≢        ⍝ do 32 minus (-) the range 0 1 ... [length of input string] (⍳∘≢)
            ⊢-            ⍝ take the right argument (⊢) [the codepoints] and subtract the previous calculation from those [effectively adding the positions and subtracting 32]
         95|               ⍝ and take those numbers modulu 95.
      ⊣+                  ⍝ Take the left (⊣) argument [32] and add it to the numbers we just did mod 95
  ⎕ucs                     ⍝ and convert the new code points to characters.

@Bubbler has a similar answer but making use of an operator that hasn't been implemented in Dyalog APL yet, check it out.

Ly, 25 bytes

ir84*sp[l-l,sp(95)%84*+o]

Try it online!

C (gcc), 48 47 46 bytes

Saved a byte thanks to 640KB!!!

Saved a byte thanks to dingledooper!!!

i;f(char*s){for(i=32;*s;)*s++=(*s-i--)%95+32;}

Try it online!

T-SQL, 100 bytes

Added some line changes to make it readable

DECLARE @x INT=0
WHILE @x<len(@)
SELECT
@=substring(@,2,999)+char((ascii(@)+@x-32)%95+32),
@x+=1
PRINT @

Try it online

Erlang (escript), 68 bytes

f(I,[H|T])->[(H+I-32)rem 95+32]++f(I+1,T);f(_,[])->[].
f(I)->f(0,I).

Try it online!

R, 56 57 bytes

function(s)intToUtf8((utf8ToInt(s)-33+1:nchar(s))%%95+32)

Try it online!

Edit: thanks to Giuseppe for bug-spotting!

I am beginning to despise string manipulations in R, and the intToUtf8() / utf8ToInt() function names in particular...

Perl 5 (-p), 32 bytes

-1 byte thanks to @Abigail

s/./chr 32+($x++-32+ord$&)%95/ge

Try it online!

C (gcc), 46 50 48 bytes

x;f(char*s){*s?*s=(*s+x++-32)%95+32,x=f(s+1):0;}

Try it online!

Jelly, 9 bytes

O+J_32ịØṖ

Try it online!

How?

O+J_32ịØṖ - Link: list of characters, S  - e.g. "zzzzzzzzz"
O         - cast (S) to ordinal values          [122,122,122,122,122,122,122,122,122]
  J       - range of length (S)                 [  1,  2,  3,  4,  5,  6,  7,  8,  9]
 +        - add (vectorises)                    [123,124,125,126,127,128,129,130,131]
    32    - thirty-two                          32
   _      - subtract                            [ 91, 92, 93, 94, 95, 96, 97, 98, 99]
       ØṖ - printable ASCII characters          " !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
      ị   - index into (1-based & modular)      "z{|}~ !"#"

05AB1E, 16 10 9 bytes

žQDIkā<+è

-1 byte by porting @Neil's Charcoal answer, so make sure to upvote him!

I/O as a list of characters.

Try it online or verify all test cases.

Explanation:

žQ          # Push the printible ASCII string builtin
  D         # Duplicate it
   I        # Push the input-list of characters
    k       # Get each index in the ASCII string
     ā      # Push the list [1, length] (without popping)
      <     # Decrease it by 1 to make it a 0-based range [0, length)
       +    # Add the values at the same positions in the lists together
        è   # Index each into the ASCII string (0-based and with automatic wraparound)
            # (after which the resulting list of characters is output implicitly)

Python 3.8, 55 54 bytes

Output is a list of characters.

lambda s,d=33:[chr((ord(c)-(d:=d-1))%95+32)for c in s]

Try it online!

Befunge-98 (FBBI), 20 bytes

'!v
-1<,+ '%_'-\~@#:

Try it online!

Initially pushes d=33 on the stack. On every iteration, d is reduced by one and (input-d)%95+32 is printed.

K (oK), 19 bytes

{`c$32+95!x-32-!#x}

Try it online!

Keg, 19 bytes

0&(⑻+:\~>[\~% +;],⑹

Try it online!

Woooo! I managed to beat APL somehow! This is a very literal interpretation of the challenge, except for the part where overflow values are decremented after modulusing.

Befunge-93, 25 bytes

:~:1+!#@_" "-+"_"%" "+,1+

Try it online!

Keeps the character count on the bottom of the stack. Then in a loop, reads a character at the time, subtracts 32 to the character, adds the character count, mods it with 95, adds 32 again, then prints the character. Finally, it adds 1 to the character count.

JavaScript (Node.js), 42 bytes

s=>Buffer(s).map((c,i)=>(c+i-32)%95+32)+''

Try it online!

Retina 0.8.2, 19 bytes

{*\M!`^.
^.

T`~p`p

Try it online! Link includes test cases. Explanation:

{

Repeat until the input is empty.

*\M!`^.

Output the first character.

^.

Remove the first character.

T`~p`p

Cyclically increment the remaining characters.

12 bytes in Retina 1:

1,Tv`~p`p`.+

Try it online! Link includes test cases. Explanation:

v`.+

Create overlapping matches that start at each character and end at the end of the string.

1,

Ignore the match of the whole input.

T`~p`p`

Cyclically shift each character according to the number of times it was matched.

Charcoal, 9 bytes

⭆S§γ⁺κ⌕γι

Try it online! Link is to verbose version of code. Explanation:

 S          Input string
⭆           Map over characters and join
        ι   Current character
      ⌕     Find position in
       γ    Printable ASCII
    ⁺       Plus
     κ      Current index
  §         Cyclically indexed into
   γ        Printable ASCII
            Implicitly print

JavaScript, 77 bytes

Iterative!

s=>[...s].map((c,i)=>String.fromCharCode((c.charCodeAt()+i-32)%95+32)).join``

Try it online!


JavaScript, 77 bytes

Outer recursive!

f=(s,i=0)=>s[i]?String.fromCharCode((s.charCodeAt(i)+i-32)%95+32)+f(s,i+1):''

Try it online!


JavaScript, 77 bytes

Inner recursive!

s=>(F=i=>s[i]?String.fromCharCode((s.charCodeAt(i)+i-32)%95+32)+F(i+1):'')(0)

Try it online!

J, 22 bytes

(95|<:+#\)&.(_32+3&u:)

Try it online!

Almost word-to-word translation of my dzaima/APL solution.

How it works

(95|<:+#\)&.(_32+3&u:)  NB. Input: string S
(   X    )&.(   Y    )  NB. The "Under" operator; do Y, do X and undo Y
             _32+3&u:   NB. Convert chars to codepoints and subtract 32
       #\               NB. One-based index
    <:+                 NB. Add to the codepoints minus 1
 95|                    NB. Modulo 95
             _32+3&u:   NB. Undo this: add 32 and convert to chars

APL (Dyalog Extended), 22 bytes (SBCS)

Full program. Requires ⎕IO←0

⍞(⊢⊇⍨95|⍳⍨+~⍋⊣)' '…'~'

Try it online!

' '…'~' the printable ASCII range

⍞() with the input as left argument, apply the following tacit function to that:

 the left argument (the input)

 the sorting permutation to sort according to the following order:

  ~ the input without any printable ASCII, i.e. an empty string (this means leave all in current positions)

⍳⍨ the indices of the input characters in the printable ASCII

95| division remainder when divided by 95

⊇⍨ use those indices to select from:

   the printable ASCII

Ruby, 42 bytes

->s{i=33;s.map{((_1.ord-i-=1)%95+32).chr}}

Takes input and returns output as an array of characters.

44 byte version because TIO doesn't support ruby 2.7's _1 syntax

->s{i=33;s.map{|c|((c.ord-i-=1)%95+32).chr}}

Try it online!

APL (dzaima/APL), 21 bytes

{95|⍵+⍳≢⍵}⍢(¯32+⎕UCS)

Try it online!

Just trying out the experimental Under operator because the task is screaming for it.

How it works

{95|⍵+⍳≢⍵}⍢(¯32+⎕UCS)  ⍝ Input: string S
          ⍢(¯32+⎕UCS)  ⍝ Convert S to Unicode codepoints and subtract 32
{   ⍵+⍳≢⍵}             ⍝ Add the index to each char
 95|                   ⍝ Modulo 95
          ⍢(¯32+⎕UCS)  ⍝ Undo the operation:
                       ⍝ Add 32 and convert back to Unicode chars