-4
\$\begingroup\$

In case the title was confusing, I mean something like the following C code:

main(){}znva(){}

When rot13 encoded, the code becomes

znva(){}main(){}

and still runs.

But that isn't a valid answer, because of these rules:

  • Your code must produce output. Code that doesn't produce output is disqualified.
  • The program can't be empty. That's disqualified too.
  • The program can't be the same or similar to the output. This means that you can't use Golfscript or PHP.

In a valid answer, the program produces some output without being rot13'd, such as:

Hello, World!

And when the program is rot13'd, the output changes to the following:

Uryyb, Jbeyq!

which is the rot13 of Hello, World!.

Have fun!

\$\endgroup\$

closed as unclear what you're asking by GamrCorps, TanMath, ETHproductions, Alex A. Dec 24 '15 at 3:40

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    \$\begingroup\$ Is this code that produces an output when it is rot13'd? Or is it code that produces an output of itself rot13'd (that produces the original program)? \$\endgroup\$ – Justin Nov 18 '13 at 22:38
  • 1
    \$\begingroup\$ Does the output have to contain letters? As it stands, . is a valid response in brainfuck. \$\endgroup\$ – Alex Gittemeier Nov 19 '13 at 1:55
  • 4
    \$\begingroup\$ BTW: what is the objective winning criteria? \$\endgroup\$ – Johannes Kuhn Nov 19 '13 at 7:57
  • 9
    \$\begingroup\$ @tbodt In the future, please refrain from changing a challenge's rules and/or judging criteria once it's been posted. If you would like to "test out" a challenge before posting it, in order to per-determine what rule modifications might be necessary, please use the current Sandbox thread in Meta. (Currently at Mk V.) \$\endgroup\$ – Iszi Nov 20 '13 at 1:01
  • 3
    \$\begingroup\$ -1 Congratulations. You now have successfuly created a chamelion quesion. The statement "assuming they [the rules] don't change again" only shows that you can't answer this without your answer beeing invalidated. \$\endgroup\$ – Johannes Kuhn Nov 20 '13 at 7:54
4
\$\begingroup\$

Ruby

Cheaty answer:

$><<'Hello, world!'

Slightly less cheaty answer:

s='Hello, world!'
$-I?puts(s):chgf(s)

Golf (15 chars)

$-I?p(:a):c(:a)
\$\endgroup\$
  • \$\begingroup\$ I changed the rules. Your second solution is the only one valid. \$\endgroup\$ – tbodt Nov 19 '13 at 19:20
  • \$\begingroup\$ This is now a code golf contest. Shorten it up. \$\endgroup\$ – tbodt Nov 19 '13 at 23:27
2
\$\begingroup\$

Perl, 25 14 12 characters

I believe this adheres to all of the requirements:

$_=a;fnl;say

Outputs a. After rot13 the program looks like this:

$_=n;say;fnl

and outputs n.

\$\endgroup\$
  • \$\begingroup\$ Does perl generate an error on encountering fnl? \$\endgroup\$ – tbodt Nov 19 '13 at 19:48
  • \$\begingroup\$ @tbodt Without strict mode (and warnings) turned on, Perl will parse fnl as "fnl" (i.e. as a string). The statement then becomes a no-op expression. \$\endgroup\$ – breadbox Nov 19 '13 at 23:18
  • \$\begingroup\$ Your solution is not disqualified. And you get an up vote. \$\endgroup\$ – tbodt Nov 19 '13 at 23:21
  • \$\begingroup\$ This is now a code golf contest. Shorten it up. \$\endgroup\$ – tbodt Nov 19 '13 at 23:22
1
\$\begingroup\$

Brainf**k

Since you never said the output had to actually be affected by rot13, this is totally a valid answer:

-.

Not sure why it was downvoted, although it is kind of a cheap answer.

\$\endgroup\$
  • \$\begingroup\$ I changed the rules. histocrat's second solution is the only one valid. \$\endgroup\$ – tbodt Nov 19 '13 at 19:19
  • \$\begingroup\$ add an letter at the end, and it will be valid. \$\endgroup\$ – Johannes Kuhn Nov 19 '13 at 21:04
  • \$\begingroup\$ @JohannesKuhn Re-changed the rules. No comments. I think that I won't have to change them again. \$\endgroup\$ – tbodt Nov 19 '13 at 23:13
  • \$\begingroup\$ You change the rules just to invalidate existing answers? \$\endgroup\$ – Johannes Kuhn Nov 20 '13 at 7:52
0
\$\begingroup\$

PHP 6

H<?//a

The program and its output differ by 83%, so not similar.
a is not transformed into output, should satisfy all rules now.

\$\endgroup\$
  • \$\begingroup\$ I changed the rules. histocrat's second solution is the only one valid. \$\endgroup\$ – tbodt Nov 19 '13 at 19:19
  • \$\begingroup\$ Because chameleon question. \$\endgroup\$ – Johannes Kuhn Nov 19 '13 at 19:33
  • \$\begingroup\$ There I fixed it. \$\endgroup\$ – Johannes Kuhn Nov 19 '13 at 19:36
  • \$\begingroup\$ What does that // do? And don't you need a ?> ending delimiter? \$\endgroup\$ – tbodt Nov 19 '13 at 19:52
  • \$\begingroup\$ // is a comment. and no, I don't need an ending ?> \$\endgroup\$ – Johannes Kuhn Nov 19 '13 at 21:03
0
\$\begingroup\$

bash, 64 chars

_() { [[ "${1:0:1}" > U ]]&&rpub $@||echo $@; };_ Hello, Jbeyq.
\$\endgroup\$

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