-5
\$\begingroup\$

This challenge is quite simple to conceptualise, but likely a lot harder to execute.

In this challenge, the program will have to detect the number N of its characters that have been randomly changed (at least half of the program will always remain). Then, it will have to output the Nth prime number.

A 'change' can only be the replacement of a character. You can assume it will always be replaced by something within your own language's alphabet.

Rules

  • Only half of your program (rounded down to fewer changes, if necessary) will ever be hit by radiation.
  • Standard output formats apply.
  • The prime number must always be correct. Regarding the 'Nth' prime, N can be 1- or 0-indexed.
  • 1 is not a prime number!
  • If nothing (or only 1 character, if you choose to make N 1-indexed) is changed, output 0/null/any falsey value.
  • This is , so shortest answer in bytes wins.
  • Standard loopholes apply.
\$\endgroup\$

closed as unclear what you're asking by Jo King, Wheat Wizard, Stephen, mbomb007, lirtosiast Jul 6 at 23:18

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\$ What kind of changes may happen? Is it possible that the very first character is changed into something outside of language alphabet, making code unacceptable by compiler/interpreter? \$\endgroup\$ – Daniil Tutubalin Jul 6 at 11:30
  • \$\begingroup\$ @DaniilTutubalin see now. \$\endgroup\$ – Geza Kerecsenyi Jul 6 at 11:42
  • 5
    \$\begingroup\$ All of your recent challenges have been either put on hold or been very poorly recieved. I strongly suggest using the Sandbox in the future to check community feedback and clear up obvious unintended loopholes before posting to main \$\endgroup\$ – Jo King Jul 6 at 12:25
  • 5
    \$\begingroup\$ I would suggest to change it this way: one (and exactly one) random character is changed. The program must find its index N and output Nth prime number. Or just output N (if its not a duplicate). \$\endgroup\$ – Daniil Tutubalin Jul 6 at 12:45
  • 1
    \$\begingroup\$ Closing as unclear because as the rules currently are, I could make a 1-character program that outputs 0 or null, and solutions longer than 3 characters seem impossible, which is probably not what the author intends. \$\endgroup\$ – lirtosiast Jul 6 at 23:18
1
\$\begingroup\$

Unary, 0 bytes

Outputs nothing as a falsey value for no change. Note that Unary only has one symbol in its alphabet, so any program outputting a falsey value would be valid, since there are no possible changes to be made.

\$\endgroup\$
1
\$\begingroup\$

GolfScript, 1 0 bytes

Rule 1 + Rule 5. Thanks to @Jo King for mentioning that empty string is falsey value.

Try it online!

GolfScript, 1 byte

0-indexed version which actually outputs a prime number (0th).

It is also JS and Python solution if we run it in interactive shell.

2

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Brainfuck, 1 byte

Outputs zero byte. Zero byte is falsey in Brainfuck.

.

Try it online!

\$\endgroup\$

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