Geiger counter prime generation

-5

1

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.

Geza Kerecsenyi

Posted 2019-07-06T09:47:02.097

Reputation: 1 892

Question was closed 2019-07-06T23:18:19.687

1What 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? – Daniil Tutubalin – 2019-07-06T11:30:29.430

@DaniilTutubalin see now. – Geza Kerecsenyi – 2019-07-06T11:42:26.590

5

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

– Jo King – 2019-07-06T12:25:08.063

5I 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). – Daniil Tutubalin – 2019-07-06T12:45:20.090

What counts as the language's alphabet? – Post Rock Garf Hunter – 2019-07-06T14:57:41.200

Anything it can parse @SriotchilismOZaic – Geza Kerecsenyi – 2019-07-06T17:31:58.133

1Closing 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. – lirtosiast – 2019-07-06T23:18:16.333

Answers

1

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!

Daniil Tutubalin

Posted 2019-07-06T09:47:02.097

Reputation: 547

1

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.

Jo King

Posted 2019-07-06T09:47:02.097

Reputation: 38 234

0

Brainfuck, 1 byte

Outputs zero byte. Zero byte is falsey in Brainfuck.

.

Try it online!

Daniil Tutubalin

Posted 2019-07-06T09:47:02.097

Reputation: 547