4
\$\begingroup\$

This is alternate of a rip-off of a rip-off of a rip-off of a rip-off of a rip-off of a rip-off. Go upvote those!

Your task, if you accept it, is to write a program/function that outputs/returns its input/args. But again, The tricky part is that if I rot-13 your source code, the output must be returned rot-19.

Your code will be only rotated once.

Examples

Let's say your source code is ABC and the input is xyz.

Code ABC should return xyz.

Code NOP(rotated) should return -./ (Rot-19).

Details

  • If your language has a custom codepage, apply rot13 to the bytes in the printable ASCII range in your code, and do not modify the rest. The input and output will be in pure printable ASCII.
  • The input only contains ASCII character.
  • use printable ASCII table for rotating
  • rot-13 means to forward 13 positions in ASCII table
  • Same applied to rot-19, which forward 19 positions instead.

Rules

  • Input can be taken in any convenient format.
  • Output can be in any convenient format as well.
  • Standard Loopholes are forbidden.

scoring

This is code-golf so the answer with the fewest amount of bytes wins.

Extra scoring rule

If there's somehow, a non-esolang appeared as a valid answer, it may considered as a better answer.

Example: python, C++, java script etc.

If you are confused with Rot

Here is a encoder to get some idea with.

Use full ACSII Table for this question’s requirement.
Use printable ASCII Table (33 ~126) for rotation!

  • Space are 32 in ASCII, which count as unprintable!
\$\endgroup\$
17
  • 2
    \$\begingroup\$ "If your language has a custom codepage, apply rot13 to the bytes in the printable ASCII range in your code, and do not modify the rest." So a language that uses a code page which doesn't include any ASCII is excluded from this challenge, right? \$\endgroup\$
    – Adám
    Mar 24, 2021 at 9:27
  • 1
    \$\begingroup\$ Is the rot13 on the ASCII subset of a custom codepage relative to the codepage or to ASCII? \$\endgroup\$
    – Adám
    Mar 24, 2021 at 9:28
  • 1
    \$\begingroup\$ So, how rot 13 and rot 19 works? \$\endgroup\$
    – tsh
    Mar 24, 2021 at 9:48
  • 4
    \$\begingroup\$ This is why it is recommended to use the sandbox for challenges before posting to main. \$\endgroup\$
    – Bubbler
    Mar 24, 2021 at 10:12
  • 2
    \$\begingroup\$ Why does rot19(xyz) = ♀♪♫? I thought it should only rotate to ASCII. Also you mention "128 char" ASCII. Does that mean we should rotate characters at the end of the ASCII range into non-printable control characters? \$\endgroup\$
    – user81655
    Mar 24, 2021 at 12:38

6 Answers 6

9
\$\begingroup\$

JavaScript (Node.js), 50 bytes

a=>01+"$25hYYXeya=>z!`TcyV01yV~$'zv,'|&&z|xx-$"&&a

Try it online!

Both versions are a function which takes a string as input and returns a string.

ROT13 code:

nJK=>8/1?Buffer(nJK).map(c=>(c-14)%94+33)+'':1/33n

Explanation

Hides tricky characters used in the ROT19 logic inside a string. The quotes map to / characters so it's just a matter of finding where to put them to make it work.

\$\endgroup\$
3
  • \$\begingroup\$ woah... I didn’t thought there would be a non-golf lang answer. congratulation! \$\endgroup\$
    – okie
    Mar 24, 2021 at 23:14
  • \$\begingroup\$ Is this allowed to use comment? \$\endgroup\$
    – tsh
    Mar 25, 2021 at 9:57
  • \$\begingroup\$ @tsh sorry for the late reply, but yes, you are allowed to use comment \$\endgroup\$
    – okie
    Apr 7, 2021 at 1:25
3
\$\begingroup\$

GolfScript, 8 bytes

#.n$,p

Try it online!

Try it online!(rot13)

\$\endgroup\$
3
\$\begingroup\$

05AB1E, 11 9 bytes

-2 thanks to ovs.

žD¦7$,!R‡

Try it online!

žD¦7$,!R‡  # full program
     ,     # output...
    $      # input

=BNO>R, 11 9 bytes

žQ¦D19._‡

a!( v# |{yv{r.

žQ¦D19._‡  # full program
        ‡  # push...
           # implicit input...
        ‡  # with each...
žQ         # ASCII character...
  ¦        # excluding the first...
        ‡  # replaced by corresponding character in...
žQ D       # ASCII characters...
  ¦        # excluding the first...
      ._   # rotated...
    19     # literal...
      ._   # characters to the left
           # implicit output
\$\endgroup\$
1
  • \$\begingroup\$ 9 bytes using transliterate. \$\endgroup\$
    – ovs
    Apr 14, 2021 at 12:39
2
\$\begingroup\$

Python 3.8 (pre-release), 75 bytes

Comment still do the trick quiet well :).

t=print(input())
#.ce\agyxx!]b\ayNV[eyybeWy\z~$'zv,'|&&zYbe \ \a \achgyzPzz

Try it online!

#J}!v{#5v{}$#566
0;print(''.join([chr((ord(i)-14)%94+33)for i in input()]))

a!( v# |{yv{r.

\$\endgroup\$
2
  • \$\begingroup\$ Doesn't this append the input reversed when rot-13'ed, rather than rot-119'ing the input? \$\endgroup\$ Apr 14, 2021 at 11:21
  • \$\begingroup\$ Ouch, sry, i will update the code, I mess up this one with palindrome one \$\endgroup\$
    – okie
    Apr 14, 2021 at 11:22
0
\$\begingroup\$

Charcoal, 96 bytes

⭆S§Φγμ⁺Σ+&+⌕Φγμι

Try it online! After ROT13, this becomes:

⭆S§Φγμ⁺Σ838⌕Φγμι

Try it online! Explanation:

 S                  Input string
⭆                   Map over characters and join
        838         Literal string `+&+` or `838`
       Σ            Digital sum i.e. 0 or 19
      ⁺             Plus
           ⌕        Index of
               ι    Current character in
             γ      ASCII characters
            Φ       Filtered where
              μ     Current index is non-zero
  §                 Index into
    γ               ASCII characters
   Φ                Filtered where
     μ              Current index is non-zero
                    Implicitly print
\$\endgroup\$
0
\$\begingroup\$

Pxem, Filename: 60 bytes + Content: 0 bytes = 60 bytes.

  • Filename (escaped): .w.o.i.c\001.+.a.d!md!T!j!b!\\!V !k!V\177!lG!|Q!vr!|KK!TKK!T!V\001!|!T
    • Actual: .w.o.i.c.+.a.d!md!T!j!b!\!V !k!V!lG!|Q!vr!|KK!TKK!T!V!|!T
  • Content: empty.

With comments

See also: Simple cat program

XX.z
# pasted cat program
.a.w.o.i.c\001.+.aXX.z
# exit
.a.dXX.z
# these literals are ignored
.a!md!T!j!b!\\!V !k!V\177!lG!|Q!vr!|KK!TKK!T!V\001!|!T

Try it online!

]'rz.

  • Filename (escaped): ;&;|;v;p\001;8;n;q.zq.a.w.o.i.c .x.c\177.yT.+^.%!.+XX.aXX.a.c\001.+.a
    • Actual: ;&;|;v;p;8;n;q.zq.a.w.o.i.c .x.c.yT.+^.%!.+XX.aXX.a.c.+.a
  • Content: empty.

With comments

XX.z
# they are just literals but discarded later
.aXX;&;|;v;p\001;8;n;q.z
# while size<2||pop!=0; do push 'q'; done
.a.zq.aXX.z
# while empty||pop!=0; do
.a.wXX.z
  # if ! empty; then putchar pop; fi
  .a.oXX.z
  # push getchar; dup; push 32;
  # while size<2||pop<pop; do
  .a.i.c .xXX.z
    # dup; push 127; while size<2||pop>pop; do
    .a.c\177.yXX.z
      # push 84; push pop+pop;
      # push 94;
      # push ((x=pop)<(y=pop))?y%x:x%y
      .aT.+^.%XX.z
      # push 33; push pop+pop;
      .a!.+XX.z
    # push X; push X; done (* idiom for BREAK statement *)
    .aXX.aXX.z
  # push X; push X; done
  .aXX.aXX.z
# dup; push 1; push pop+pop; done
.a.c\001.+.a

a!( v# |{yv{r.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.