ROT-13 przekształca standardowe wejście


34

Wyzwanie: odczytać dane wejściowe o dowolnej długości i wygenerować ROT13 danych wejściowych. Wszystkie znaki oprócz AZ należy skopiować dosłownie na wyjście, a jeśli to możliwe, należy zachować wielkość liter.

Każdy język, który potrafi czytać i pisać standardowe strumienie, jest uczciwą grą.


3
Problemem nie powinien być tag, więc usunąłem ROT13, tylko FYI
Nick Berardi

2
Nie masz na myśli A-Za-z (aby liczyć zarówno wielkie, jak i małe litery)?
Joey Adams

5
@Chris Jester-Young, należy do tej kategorii na wikipedii. To część kryptografii, ale nie najtrudniejsza. W każdym razie nie śledzę już tej witryny. Społeczność mnie rozczarowała. Przepraszam. GL HF.
Nakilon 30.01.11

17
Powiedzenie, że xor nie jest szyfrowaniem, jest jak powiedzenie, że a + b to nie matematyka .
Nakilon,

3
Tagi służą do kategoryzacji pytań i pomagają wyszukiwać podobne pytania. Znacznik kryptograficzny (z greckiego kryptós, „ukryty, tajny” i grafhein, „pisanie”) w szczególności dotyczy problemów z szyfrowaniem i deszyfrowaniem. Wszystkie szyfrowania i deszyfrowania, nie tylko te, które są bezpieczne dla nowoczesnych aplikacji.
Angs,

Odpowiedzi:


25

Bash, 23 bajty

Kanoniczna odpowiedź na 23 znaki:

tr A-Za-z N-ZA-Mn-za-m

1
W tej chwili nie mam dostępu do bash, ale myślę, że to powinno działać: tr A-za-m N-ZA-z(16 znaków)
Nabb

2
@Nabb: Miło cię widzieć, GolfScript-meister! : -Myślę, że twoje rozwiązanie tutaj złamałoby warunek, że „Wszystkie znaki oprócz AZ powinny być kopiowane dosłownie na wyjście”.
Chris Jester-Young,

@Chris: Tak, wygląda na to, że masz rację.
Nabb

@Nabb: Nie, dla mnie wygląda na to, że się myli. A może możesz pokazać przykład?
użytkownik nieznany

2
@ użytkownik nieznany: wpisz [\\]^_`dane wejściowe. Wróci NOPQRSraczej niż [\\]^_`, przynajmniej w wersji, trktórą mam. (To jest sześć znaków w ASCII, które leżą między Za a. Oczywiście wszystkie inne postacie będą działać poprawnie.)
Chris Jester-Young

20

Bash - 5 znaków

rot13

 


18
Do tej pory dwie opinie negatywne (bez komentarzy), ale brak ocen negatywnych dla tego pytania. Zakładam, że oznacza to, że można zadawać trywialne golfy, ale nie udzielać trywialnych odpowiedzi. Twardsze codegolfs proszę!
gnibbler 30.01.11

8
Która wersja bash? Nie mam wbudowanej zgnilizny 13. bash --version GNU bash, Version 4.0.33(1)-release (i486-pc-linux-gnu)
użytkownik nieznany

12
rot13 - 0 chars
Podałbym

2
To jest mój przyjaciel, nie Bash
TheDoctor

3
erm ... nie. mój bash (Ubuntu 13.10) mówi „nie znaleziono polecenia, możesz zainstalować ten program do sudo apt-get install bsdgames

17

Python 2, 34 bajty

print raw_input().encode('rot13')

1
-1 Myślę, że oszukujesz, że używasz wbudowanej biblioteki.
Glenn Nelson

16
Używałem ich w każdym kodzie golfowym, w którym brałem udział ... Także jeśli używanie standardowej biblioteki Pythona to oszustwo, to jak używasz tr?
Juan

3
@Anon W każdym razie jest to odpowiedź, którą po prostu zignorujesz. To nie jest cel, nie ma żadnych reguł ustalonych przez OP ani przez społeczność. Jasne, może moje nie jest nagradzanym rozwiązaniem, takim jak ten, który używa tr, który kopie tyłek. Ale to nie żart, wykorzystuję moc Pythona, aby zmniejszyć liczbę, tak jak każdy inny.
Juan

2
@Glenn: wręcz przeciwnie, nigdy nie widziałem czegoś takiego jak golf. Ani nie kodegolf.com, golf.shinh.org lub SPOJ SHORTEN.
hallvabo 27.01.11

9
@Glenn, myślę, że funkcje biblioteczne są uczciwą grą. Od golfa zależy, czy będzie wystarczająco interesujący, aby nie znajdować się w czyjejś bibliotece ani go wykluczyć.
gnibbler 28.01.11

15

Befunge - 7x30 = 210 6x26 = 156 znaków

Nowa wersja przesyłania strumieniowego, która obsługuje zarówno duże, jak i małe litery i powinna obsługiwać nieograniczoną liczbę wejść.

v,<               <<     <
  ^-4-9<    >:"A"\`|
     >:"a"\`|     #>:"Z"`|
>~:0`| #    >:"z"`|
,    @ |    <`"m":<v`"M":<
^  +4+9<    ^      <

Stara wersja

Przechowuje wartości wewnątrz własnego kodu źródłowego. Naprawdę pokazuje, jak okropnie jest próbować wysyłać zapisane wartości w tej samej kolejności, w jakiej je otrzymujesz. Obsługuje tylko małe litery.

vp0p11:+1g11<      < <
v                    ^-4-9<
v    >:"a"\`|>:"z"`|>:"m"`|
>~:0`|      >^     >^#
                     ^+4+9<
     >$011g1+0p>12g1+:12p0g:v
               ^           ,_@

Nie jestem pewien, jakie dokładnie to ma ograniczenia, używając http://www.quirkster.com/iano/js/befunge.html jako interpretera, który wydaje się łamać przy dużych nakładach.


Możesz usunąć białe znaki na końcu linii.
Zacharý

10

Rubin - 60 57 38 37 znaków

Edycja: I właśnie zrealizowane ciągi Ruby mają trmetodę.

puts$<.read.tr'A-Za-z','N-ZA-Mn-za-m'

Test

input = "The challenge: To read an input of arbitrary length and produce the ROT13 of the input. All characters besides A-Z should be copied to the output verbatim, and case should be preserved if possible.

Any language that can read and write standard streams is fair game."

output = `echo '#{input}' | ruby golf-rot13.rb`

puts "Input:"
puts input
puts "-------"
puts "Output:"
puts output

Daje:

Input:
The challenge: To read an input of arbitrary length and produce the ROT13 of the input. All characters besides A-Z should be copied to the output verbatim, and case should be preserved if possible.

Any language that can read and write standard streams is fair game.
-------
Output:
Gur punyyratr: Gb ernq na vachg bs neovgenel yratgu naq cebqhpr gur EBG13 bs gur vachg. Nyy punenpgref orfvqrf N-M fubhyq or pbcvrq gb gur bhgchg ireongvz, naq pnfr fubhyq or cerfreirq vs cbffvoyr.

Nal ynathntr gung pna ernq naq jevgr fgnaqneq fgernzf vf snve tnzr.

Nie potrzebujesz już miejsca puts, a „Az” to skrót od „A-Za-z”
Ventero

1
@Ventro: Dzięki, po drobnych testach wygląda na to, że 'A-z'to 'A-Z[\]^_a-z ' , damn ascii having characters between Z` i a.
Nemo157

1
Zasadniczo taka sama, ale 35 znaków: puts gets.tr'A-Za-z','N-ZA-Mn-za-m'.
Michael Kohl

@ Michael: Z wyjątkiem tego, getsże zwraca tylko pierwszą linię, używając $ <. Read czyta do EOF. Pytanie nie mówi nic o tym, czy dane wejściowe mogą zawierać nowe wiersze, więc popełniłem błąd po stronie ostrożności.
Nemo157

W porządku, ale ponieważ specyfikacja ćwiczenia wspomniała tylko o „arbitralnej długości”, ale nie mówiła nic o nowych liniach, wolałabym się mylić po stronie zwięzłości w codegolf ;-)
Michael Kohl

10

vim, 5 naciśnięć klawiszy

Zakładając, że tryb normalny i tekst jest już zapisany w buforze:

ggg?G

Lub następujące konwencje vimgolfa:

g?GZZ

Możesz także wywołać go jako polecenie terminalu, coś w stylu:

$ vim -c 'norm g?G' -
< your text here ...
... multiple lines if you want ...
... terminate input with ctrl+D on a blank line >

Wydaje mi się, że ten ostatni liczyłby się jako „program” składający się z 8 znaków ( norm g?G)


norm g?Gjest skrótem, normal g?Gco daje 8 znaków.
Patrick Oscity,

Myślę, że możesz bezpiecznie założyć, że zaczynasz od linii 1, więc pierwszą ggmożna przerwać. Powiedziałbym 3 naciśnięcia klawiszy, gdy plik jest otwarty.
Patrick Oscity,

1
If we use vimgolf's conventions (you start in a vanilla vim having just opened the file, but need to save and quit) we also get 5 (g?GZZ).
FireFly

7

C - 83 79 characters

main(c,b){while((c=getchar())>=0)b=c&96,putchar(isalpha(c)?b+1+(c-b+12)%26:c);}

Readable version:

#include <ctype.h>
#include <stdio.h>

int main(void)
{
    int c, base;

    while ((c = getchar()) >= 0) {
        if (isalpha(c)) {
            base = (c & 96) + 1; /* First letter of the upper or lower case. */
            c = base + (c - base + 13) % 26;
        }
        putchar(c);
    }

    return 0;
}

1
Are you including the headers you include in your count?
JPvdMerwe

@JPvdMerwe: I didn't include any headers in the golfed version, nor did I need to.
Joey Adams

You can use the coma operator before putchar to remove a pair of braces.
Alexandru

Could you explain main(c,b)? It's the first time i see this.
Alexandru

2
@Alexandru most C compilers support main with any parameters. Also, the original C standard defines that an argument with no type is an int. Thus you get to declare ints without actually writing int.
Juan

7

Python (117 bytes)

Here's a Python version that avoids the rot13()-method.

import sys
print"".join([chr(x/32*32+1+(x%32+12)%26if 64<x<91or 96<x<123 else x)for x in map(ord,sys.stdin.read())])

raw_input returns one line not all input.
Alexandru

you need to import sys and use sys.stdin.read().
Alexandru

@Alexandru: will do
JPvdMerwe

-2 bytes if you eliminate the [] to make the list comp a generator: tio.run/…
connectyourcharger

7

tr/// solution in Perl (39 characters), boilerplate can be removed with -p:

while(<>){y/a-zA-Z/n-za-mN-ZA-M/;print}

Using -p (23 characters including the extra switch):

perl -pe'y/a-zA-Z/n-za-mN-ZA-M/'

Add 1 char for the p, but please remove the boilerplate!
J B

7

R, 37 bytes

example("chartr");cat(rot(scan(,"")))

example("chartr") runs the examples for chartr, which includes the rot function, which is ROT13 by default....


5

DC (111 108 for the dc itself)

Ok, here it is in (mostly) dc and some sed and od magic to get it into the right format for the code. If you don't count the input thing (echo -n MESSAGE |) it's 160 bytes:

od -An -t dC|sed 's/^\ *//;s/\ \{2,3\}/\n/g'|dc -e'[13+26%]sm[65-lmx65+]su[97-lmx97+]sl[96<b64<dPc]sa[91>c]sd[123>e]sb[lux]sc[llxdd]se[ddddlaxlrx]sy[?z0<y]dsrx'

As a point of interest, the dc programme itself is only a 108 bytes long, shorter than the non-library python version. It even preserves case and punctuation, and beats Javascript in the above submission! If only I could better parse the output of od, or better yet replace it altogether.

EDIT: It's worth noting that the question doesn't indicate a trailing new line 10P which saves me three further bytes.

EDIT 2: There's no specification for the format of the input, so I assume it's taken in as is convenient for my programme :P


5

Befunge-93, 85 (grid: 41x3=123)

This is an ancient question, but I thought I'd revive it to post a slightly nicer Befunge answer.

#v_~::" "/2%" "*-::"@"`!#v_"Z"#v`#!_1
v> "M"`2*1\-34*1+*+    1:>$!   _:"."-!#@_
>,^

You can test it here. Enter a single character at a time; it terminates upon entering a . character (you can change that by modifying the "." near the right side of the second row). Works with upper and lower case, as well as punctuation, and with no limit to input.

I don't expect this to get a ton of upvotes or anything, but I just wanted to demonstrate how awesome Befunge actually is that you can do a little better than the other answer.

I could probably make it even shorter in Befunge-98.


You can add my snippet from here to have an inline interpreter, if you want. :)
Ingo Bürk

Ooh, I haven't really investigated snippets yet. I'll take a look, thanks!
Kasran

This doesn't work if there is a space in the input. It goes into an infinite loop in the sequence >$! _ because you've got two zeros on the stack at that point when you are expecting a non-zero value.
James Holderness

4

PHP - 103 98 80 characters

(not using str_rot13())

<?=preg_replace('#[a-zA-Z]#e','chr(($x=ord("\0"))-$x%32+1+($x%32+12)%26)',`cat`);

4

Delphi, 110

var c:Char;begin repeat Read(c);Write(Chr(Ord(c)+(Ord(c in['A'..'M'])-Ord(c in['N'..'Z']))*13));until EOF;end.

var c:Char;begin repeat Read(c);Write(Chr(Ord(c)+(Ord(c in['A'..'M'])-Ord(c in['N'..'Z']))*13));until EOF;end. saves one character :)
Wouter van Nifterick

@Wouter van Nifterick : Good spot! I'll update it accordingly
PatrickvL

4

Haskell, 100 characters

a%b=([a..b]++)
main=interact$map$toEnum.((0%64$78%90$65%77$91%96$110%122$97%109$[123..])!!).fromEnum


3

Java 251 chars

public class r{public static void main(String[] a){String s = a[0];for(int i=0;i<s.length();){char c=s.charAt(i++);if(c>='a'&&c<='m')c+=13;else if(c>='n'&&c<='z')c-= 13;else if(c>='A'&&c<='M')c+=13;else if(c>='A'&&c <='Z')c-=13;System.out.print(c);}}}

3

Python 3 (107)

Ok, I promise to stop answering this question now, but I felt compelled to beat the DC answer in Python. This probably reflects poorly on me as a person :).

import sys;[print(x.isalpha()and chr((ord(x)&96)+1+(ord(x)%32+12)%26)or x,end='')for x in sys.stdin.read()]

3

C: 69 68 characters

Alright, I know this thread is long dead, but I couldn't stand the (long) C-solution which doesn't even compile on Clang (but does on GCC).

main(c){putchar(isalpha(c=getchar())*((c|32)<110?13:-13)+c);main();}

It is probably almost still squeezable. It certainly was squeezable. And not only was it squeezable, it was possible to make it recursive.


3

05AB1E, 13 12 bytes

Saved a byte thanks to robbie0630

ADu)øJD2äRJ‡

Try it online!

Explanation

ADu           # push lower-case and uppercase alphabet
   )øJ        # zip, flatten and join, producing aAbB..zZ
      D2äRJ   # split a copy in 2 pieces, reverse and join producing nNoO..mM
           ‡  # translate input by replacing members of the alphabet 
              # with the corresponding member of the rot-13 alphabet
              # implicitly display

I ran through this with --debug, and it seems like the ˜ is a no-op in this case and can be cut out.
robbie

@robbie0630: True. No idea why I had that in. Thank you :)
Emigna


2

JavaScript 1.8, 106

alert(prompt().replace(/\w/g,function(c)String.fromCharCode(c.charCodeAt()+(c.toLowerCase()<'n'?13:-13))))

JavaScript, 115

alert(prompt().replace(/\w/g,function(c){return String.fromCharCode(c.charCodeAt()+(c.toLowerCase()<'n'?13:-13))}))

This solution solves the problem by adding 13 to the character code if the character in question is in the first half of the alphabet, or subtracting 13 if it's in the second half.


You can save 7 characters by replacing +(c.toLowerCase()<'n'?13:-13)) with -13+26*/[a-m]/i.test(c).
Jacob

2

CHIQRSX9+, 1

R

You just have to use the right tool for the problem.
CHIQRSX9+ is Turing complete, and it can read and write from standard channels with C.


5
@nyuszika7h The language was invented before this question was written, so it is valid.
Johannes Kuhn

1
It's still one of the things it was invented for, though. Seems like cheating to me.
nyuszika7h

7
@nyuszika7h And golfscript was invented to win in code-golf challenges. Do you think that is cheating too?
Johannes Kuhn

2
@Mego It's hardly fair to apply those standards here when they were written a year after this answer.
Doorknob


2

C, 136 bytes

I have never felt like any of my solutions are good enough to post on here, but made this for fun, and figured that it will be my gateway drug into code golf.

#define z(x) c>=x&&c<x+13
#define q(w) c>=w&&c<w+13
main(c){for(;(c=getchar())>=0;putchar(z('A')||z('a')?c+13:q('M')||q('m')?c-13:c));}

4
Welcome to Programming Puzzles and Code Golf Stack Exchange. Great first answer. And just for the record, we all feel that way sometimes, just know that anything that you create is "good enough" somewhere.
GamrCorps

2
Everything here on PPCG is just for fun (or imaginary internet points) -- please, don't feel the work you've done to craft a solution isn't "good enough"
cat

Thanks for all the support. I think posting something was all I needed to get my head in gear. I am going to try my hand at more of these challenges soon.
Tormyst

2

Javascript, 177 bytes

This assumes that there are two functions, print and readLine:

f=String.fromCharCode;print(readLine().replace(/[a-z]/g,function(a){return f((a.charCodeAt(0)-84)%25+97);}).replace(/[A-Z]/g,function(a){return f((a.charCodeAt(0)-52)%25+65);}))

2

LispLisp (16,636)

I'm sorry.

((((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
  (lisp lisp))
 (((lisp (lisp (lisp (lisp lisp))))
   ((lisp (lisp (lisp lisp)))
    ((lisp (lisp (lisp (lisp lisp))))
     (((lisp (lisp (lisp (lisp lisp))))
       ((lisp (lisp (lisp lisp)))
        (((lisp (lisp (lisp (lisp lisp))))
          (((lisp (lisp (lisp (lisp lisp))))
            ((lisp (lisp (lisp lisp)))
             (lisp (lisp (lisp (lisp lisp))))))
           (((lisp (lisp (lisp (lisp lisp))))
             ((lisp (lisp (lisp lisp)))
              (lisp (lisp (lisp lisp)))))
            (((lisp (lisp (lisp (lisp lisp))))
              ((lisp (lisp (lisp lisp)))
               (lisp (lisp (lisp (lisp lisp))))))
             (((lisp (lisp (lisp (lisp lisp))))
               ((lisp (lisp (lisp lisp)))
                ((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))))
              (lisp (lisp (lisp lisp))))))))
         ((lisp (lisp (lisp lisp)))
          (lisp (lisp (lisp lisp)))))))
      (((lisp (lisp (lisp (lisp lisp))))
        ((lisp (lisp (lisp lisp)))
         (((lisp (lisp (lisp (lisp lisp))))
           (((lisp (lisp (lisp (lisp lisp))))
             ((lisp (lisp (lisp lisp)))
              (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
               ((lisp (lisp (lisp lisp)))
                (lisp (lisp (lisp lisp)))))))
            (((lisp (lisp (lisp (lisp lisp))))
              (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
               ((lisp (lisp (lisp lisp)))
                (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                 ((lisp (lisp (lisp lisp)))
                  ((lisp (lisp (lisp lisp))) (lisp lisp)))))))
             ((lisp (lisp (lisp lisp)))
              (((((lisp (lisp (lisp (lisp lisp))))
                  (((lisp (lisp (lisp (lisp lisp))))
                    ((lisp (lisp (lisp lisp)))
                     (lisp (lisp (lisp (lisp lisp))))))
                   (lisp (lisp (lisp lisp)))))
                 ((((lisp (lisp (lisp (lisp lisp))))
                    ((lisp (lisp (lisp (lisp lisp))))
                     (((lisp (lisp (lisp (lisp lisp))))
                       ((lisp (lisp (lisp lisp)))
                        (lisp (lisp (lisp (lisp lisp))))))
                      (lisp (lisp (lisp lisp))))))
                   (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                    (lisp lisp)))
                  (((lisp (lisp (lisp (lisp lisp))))
                    (((lisp (lisp (lisp (lisp lisp))))
                      ((lisp (lisp (lisp lisp)))
                       (lisp (lisp (lisp (lisp lisp))))))
                     (lisp (lisp (lisp lisp)))))
                   (lisp lisp))))
                (((lisp (lisp (lisp (lisp lisp))))
                  ((lisp (lisp (lisp lisp)))
                   ((lisp (lisp (lisp (lisp lisp))))
                    (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                     ((lisp (lisp (lisp lisp))) (lisp lisp))))))
                 (lisp (lisp (lisp lisp)))))
               ((((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                 (((lisp (lisp (lisp (lisp lisp))))
                   ((lisp (lisp (lisp lisp)))
                    ((((lisp (lisp (lisp (lisp lisp))))
                       (((lisp (lisp (lisp (lisp lisp))))
                         ((lisp (lisp (lisp lisp)))
                          (lisp (lisp (lisp (lisp lisp))))))
                        (lisp (lisp (lisp lisp)))))
                      (lisp lisp))
                     ((((lisp (lisp (lisp (lisp lisp))))
                        (((lisp (lisp (lisp (lisp lisp))))
                          ((lisp (lisp (lisp lisp)))
                           (lisp (lisp (lisp (lisp lisp))))))
                         (lisp (lisp (lisp lisp)))))
                       (((lisp (lisp (lisp (lisp lisp))))
                         (((lisp (lisp (lisp (lisp lisp))))
                           ((lisp (lisp (lisp lisp)))
                            (lisp (lisp (lisp (lisp lisp))))))
                          (lisp (lisp (lisp lisp)))))
                        (lisp lisp)))
                      (((lisp (lisp (lisp (lisp lisp))))
                        ((lisp (lisp (lisp lisp)))
                         ((lisp (lisp (lisp (lisp lisp))))
                          (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                           ((lisp (lisp (lisp lisp))) (lisp lisp))))))
                       (lisp (lisp (lisp lisp))))))))
                  (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                   ((lisp (lisp (lisp lisp)))
                    ((((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                      (lisp lisp))
                     (((lisp (lisp (lisp (lisp lisp))))
                       ((lisp (lisp (lisp lisp)))
                        (((lisp (lisp (lisp (lisp lisp))))
                          ((lisp (lisp (lisp lisp)))
                           ((lisp (lisp (lisp (lisp lisp))))
                            (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                             ((lisp (lisp (lisp lisp))) (lisp lisp))))))
                         (lisp (lisp (lisp lisp))))))
                      (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                       (lisp lisp))))))))
                (((lisp (lisp (lisp (lisp lisp))))
                  ((lisp (lisp (lisp lisp)))
                   ((((lisp (lisp (lisp (lisp lisp))))
                      (((lisp (lisp (lisp (lisp lisp))))
                        ((lisp (lisp (lisp lisp)))
                         (lisp (lisp (lisp (lisp lisp))))))
                       (lisp (lisp (lisp lisp)))))
                     (((lisp (lisp (lisp (lisp lisp))))
                       ((lisp (lisp (lisp lisp)))
                        (((lisp (lisp (lisp (lisp lisp))))
                          (((lisp (lisp (lisp (lisp lisp))))
                            ((lisp (lisp (lisp lisp)))
                             (lisp (lisp (lisp (lisp lisp))))))
                           (lisp (lisp (lisp lisp)))))
                         (((lisp (lisp (lisp (lisp lisp))))
                           (((lisp (lisp (lisp (lisp lisp))))
                             ((lisp (lisp (lisp lisp)))
                              (lisp (lisp (lisp (lisp lisp))))))
                            (lisp (lisp (lisp lisp)))))
                          (lisp lisp)))))
                      ((((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                        (lisp lisp))
                       (((lisp (lisp (lisp (lisp lisp))))
                         (((lisp (lisp (lisp (lisp lisp))))
                           ((lisp (lisp (lisp lisp)))
                            (lisp (lisp (lisp (lisp lisp))))))
                          (lisp (lisp (lisp lisp)))))
                        (lisp lisp)))))
                    (((lisp (lisp (lisp (lisp lisp))))
                      ((lisp (lisp (lisp lisp)))
                       ((lisp (lisp (lisp (lisp lisp))))
                        (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                         ((lisp (lisp (lisp lisp)))
                          ((((lisp (lisp (lisp (lisp lisp))))
                             (((lisp (lisp (lisp (lisp lisp))))
                               ((lisp (lisp (lisp lisp)))
                                (lisp (lisp (lisp (lisp lisp))))))
                              (lisp (lisp (lisp lisp)))))
                            (((lisp (lisp (lisp (lisp lisp))))
                              ((lisp (lisp (lisp lisp)))
                               (((lisp (lisp (lisp (lisp lisp))))
                                 (((lisp (lisp (lisp (lisp lisp))))
                                   ((lisp (lisp (lisp lisp)))
                                    (lisp (lisp (lisp (lisp lisp))))))
                                  (lisp (lisp (lisp lisp)))))
                                (((lisp (lisp (lisp (lisp lisp))))
                                  (((lisp (lisp (lisp (lisp lisp))))
                                    ((lisp (lisp (lisp lisp)))
                                     (lisp (lisp (lisp (lisp lisp))))))
                                   (lisp (lisp (lisp lisp)))))
                                 (lisp lisp)))))
                             ((((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                               (lisp lisp))
                              (((lisp (lisp (lisp (lisp lisp))))
                                (((lisp (lisp (lisp (lisp lisp))))
                                  ((lisp (lisp (lisp lisp)))
                                   (lisp (lisp (lisp (lisp lisp))))))
                                 (lisp (lisp (lisp lisp)))))
                               (lisp lisp)))))
                           ((lisp (lisp (lisp (lisp lisp))))
                            (((lisp (lisp (lisp (lisp lisp))))
                              ((lisp (lisp (lisp lisp)))
                               (lisp (lisp (lisp (lisp lisp))))))
                             (lisp (lisp (lisp lisp)))))))))))
                     (lisp (lisp (lisp lisp)))))))
                 ((((lisp (lisp (lisp (lisp lisp))))
                    (((lisp (lisp (lisp (lisp lisp))))
                      ((lisp (lisp (lisp lisp)))
                       (lisp (lisp (lisp (lisp lisp))))))
                     (lisp (lisp (lisp lisp)))))
                   (((lisp (lisp (lisp (lisp lisp))))
                     ((lisp (lisp (lisp lisp)))
                      (((lisp (lisp (lisp (lisp lisp))))
                        (((lisp (lisp (lisp (lisp lisp))))
                          ((lisp (lisp (lisp lisp)))
                           (lisp (lisp (lisp (lisp lisp))))))
                         (lisp (lisp (lisp lisp)))))
                       (((lisp (lisp (lisp (lisp lisp))))
                         (((lisp (lisp (lisp (lisp lisp))))
                           ((lisp (lisp (lisp lisp)))
                            (lisp (lisp (lisp (lisp lisp))))))
                          (lisp (lisp (lisp lisp)))))
                        (lisp lisp)))))
                    ((((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                      (lisp lisp))
                     (((lisp (lisp (lisp (lisp lisp))))
                       (((lisp (lisp (lisp (lisp lisp))))
                         ((lisp (lisp (lisp lisp)))
                          (lisp (lisp (lisp (lisp lisp))))))
                        (lisp (lisp (lisp lisp)))))
                      (lisp lisp)))))
                  (((lisp (lisp (lisp (lisp lisp))))
                    ((lisp (lisp (lisp lisp)))
                     ((lisp (lisp (lisp (lisp lisp))))
                      (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                       ((lisp (lisp (lisp lisp)))
                        (((lisp (lisp (lisp (lisp lisp))))
                          ((lisp (lisp (lisp lisp)))
                           (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                            ((lisp (lisp (lisp lisp)))
                             (lisp (lisp (lisp lisp)))))))
                         (((lisp (lisp (lisp (lisp lisp))))
                           (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                            ((lisp (lisp (lisp lisp)))
                             (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                              ((lisp (lisp (lisp lisp)))
                               ((lisp (lisp (lisp lisp))) (lisp lisp)))))))
                          ((lisp (lisp (lisp lisp)))
                           (((((lisp (lisp (lisp (lisp lisp))))
                               (((lisp (lisp (lisp (lisp lisp))))
                                 ((lisp (lisp (lisp lisp)))
                                  (lisp (lisp (lisp (lisp lisp))))))
                                (lisp (lisp (lisp lisp)))))
                              (((lisp (lisp (lisp (lisp lisp))))
                                ((lisp (lisp (lisp lisp)))
                                 (((lisp (lisp (lisp (lisp lisp))))
                                   (((lisp (lisp (lisp (lisp lisp))))
                                     ((lisp (lisp (lisp lisp)))
                                      (lisp (lisp (lisp (lisp lisp))))))
                                    (lisp (lisp (lisp lisp)))))
                                  (((lisp (lisp (lisp (lisp lisp))))
                                    (((lisp (lisp (lisp (lisp lisp))))
                                      ((lisp (lisp (lisp lisp)))
                                       (lisp (lisp (lisp (lisp lisp))))))
                                     (lisp (lisp (lisp lisp)))))
                                   (lisp lisp)))))
                               ((((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                                 (lisp lisp))
                                (((lisp (lisp (lisp (lisp lisp))))
                                  (((lisp (lisp (lisp (lisp lisp))))
                                    ((lisp (lisp (lisp lisp)))
                                     (lisp (lisp (lisp (lisp lisp))))))
                                   (lisp (lisp (lisp lisp)))))
                                 (lisp lisp)))))
                             (((lisp (lisp (lisp (lisp lisp))))
                               ((lisp (lisp (lisp lisp)))
                                ((lisp (lisp (lisp (lisp lisp))))
                                 (((lisp (lisp (lisp (lisp lisp))))
                                   (lisp lisp))
                                  ((lisp (lisp (lisp lisp))) (lisp lisp))))))
                              (lisp (lisp (lisp lisp)))))
                            (((((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                               (lisp lisp))
                              (((lisp (lisp (lisp (lisp lisp))))
                                ((lisp (lisp (lisp lisp)))
                                 ((lisp (lisp (lisp (lisp lisp))))
                                  (((lisp (lisp (lisp (lisp lisp))))
                                    ((lisp (lisp (lisp lisp)))
                                     (lisp (lisp (lisp (lisp lisp))))))
                                   (((lisp (lisp (lisp (lisp lisp))))
                                     ((lisp (lisp (lisp lisp)))
                                      ((lisp (lisp (lisp (lisp lisp))))
                                       (lisp lisp))))
                                    (lisp (lisp (lisp lisp))))))))
                               (((lisp (lisp (lisp (lisp lisp))))
                                 ((lisp (lisp (lisp lisp)))
                                  ((lisp (lisp (lisp (lisp lisp))))
                                   ((lisp (lisp (lisp lisp)))
                                    (lisp (lisp (lisp lisp)))))))
                                (((lisp (lisp (lisp (lisp lisp))))
                                  (((lisp (lisp (lisp (lisp lisp))))
                                    ((lisp (lisp (lisp lisp)))
                                     (lisp (lisp (lisp (lisp lisp))))))
                                   (((lisp (lisp (lisp (lisp lisp))))
                                     ((lisp (lisp (lisp lisp)))
                                      (lisp (lisp (lisp lisp)))))
                                    (((lisp (lisp (lisp (lisp lisp))))
                                      (lisp lisp))
                                     (lisp lisp)))))
                                 ((lisp (lisp (lisp lisp)))
                                  ((lisp (lisp (lisp (lisp lisp))))
                                   (((lisp (lisp (lisp (lisp lisp))))
                                     ((lisp (lisp (lisp lisp)))
                                      (lisp (lisp (lisp (lisp lisp))))))
                                    (lisp (lisp (lisp lisp))))))))))
                             ((lisp (lisp (lisp lisp))) (lisp lisp))))))))))))
                   (lisp (lisp (lisp lisp))))))))))))
          (lisp lisp))))
       (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
        ((lisp (lisp (lisp lisp)))
         (lisp (lisp (lisp lisp))))))))))
  (((lisp (lisp (lisp (lisp lisp))))
    (((lisp (lisp (lisp (lisp lisp))))
      ((lisp (lisp (lisp lisp)))
       (lisp (lisp (lisp (lisp lisp))))))
     (((lisp (lisp (lisp (lisp lisp))))
       ((lisp (lisp (lisp lisp)))
        (lisp (lisp (lisp lisp)))))
      (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
       (lisp lisp)))))
   ((lisp (lisp (lisp lisp)))
    (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
     ((lisp (lisp (lisp lisp)))
      ((lisp (lisp (lisp lisp))) (lisp lisp))))))))

Is this an actual language with an implementation? If so, can you please link to it?
Jo King


@BenjaminUrquhart Yes, Lisp is a language. Lisplisp however, I have found no evidence exists
Jo King


1
Here's a translator to LazyK (Itself simply an implementation of the SKI Combinator Calculus). gist.github.com/SYZYGY-DEV333/d74ca36b9a4c504b25c0a2380203c98d
SYZYGY-DEV 333

2

8086 Machine Code, 27 bytes

Unassembled:

        STLOOP:
AC          LODSB               ; load byte from SI into AL, advance SI 
8B D0       MOV  DX, AX         ; save original char in DL 
0C 20       OR   AL, 020H       ; lowercase the char 
3C 61       CMP  AL, 'a'        ; is char less than 'a'? 
7C 0F       JL   STCHR          ; if so, do not rotate 
3C 7A       CMP  AL, 'z'        ; is char greater than 'z'? 
7F 0B       JG   STCHR          ; if so, do not rotate 
B6 0D       MOV  DH, 'n'-'a'    ; add or subtract 13 
3C 6E       CMP  AL, 'n'        ; is char less than 'n'? 
7C 02       JL   ADD13          ; if so, add positive 13 
F6 DE       NEG  DH             ; otherwise add -13 
        ADD13:
92          XCHG AX, DX         ; original char back to AL 
02 C4       ADD  AL, AH         ; add 13 or -13 to original char
        STCHR:
AA          STOSB               ; store converted byte into DI, advance DI 
E2 E5       LOOP STLOOP         ; continue loop through string

Input string in SI, length in CX. Output string buffer at DI.

Test IBM PC DOS program output:

enter image description here

Download R13.COM test program (PC DOS).


1

Haskell - 112 characters

r l=drop 13 l++take 13 l
t=['a'..'z']
s=['A'..'Z']
main=interact$map(\x->maybe x id$lookup x$zip(t++s)$r t++r s)


1

Tcl, 74 chars

package require [set c tcl::transform::rot];$c 13 stdin;fcopy stdin stdout
Korzystając z naszej strony potwierdzasz, że przeczytałeś(-aś) i rozumiesz nasze zasady używania plików cookie i zasady ochrony prywatności.
Licensed under cc by-sa 3.0 with attribution required.