16
2
Simply put, your goal is to create a complete program that modifies its own source code until every character of the source is different than what it started as.
Please include the beginning source as well as the ending source in your post, as well as a description. E.g. Describe what (else) your program does, the language you used, your strategy, etc.
Rules
- Your program must halt sometime after the modification is complete.
- It must actually modify its own, currently running source code (not necessarily the file you passed to the interpreter, it modifies its instructions), not print a new program or write a new file.
- Standard loopholes are disallowed.
Shortest program wins.
If your language can modify its own file and execute a new compiler process, but cannot modify its own (currently running) source code, you may write such a program instead at a +20% bytes penalty, rounded up. Real self-modifying languages should have an advantage.
Edit: If your program halts with errors, please specify it as such (and maybe say what the errors are.)
7Do I understand correctly that the program should modify its own source while it is running, in a way that potentially affects its behavior? This would rule out most non-esoteric languages. Or is it allowed to modify the source and launch a new interpreter/compiler process on it? – Zgarb – 2015-10-07T18:38:01.397
@Zgarb It must actually modify its own, currently running source code. Yes, that rules out most languages. – mbomb007 – 2015-10-07T18:39:04.677
8@mbomb007 That's bad. – mınxomaτ – 2015-10-07T18:41:04.900
1@mbomb007 It's says nowhere in you challenge that it has to run the modified source code. – mınxomaτ – 2015-10-07T18:42:39.273
1Also, no it doesn't make this challenge trivial, it'll still good scoped. You ruled out too many languages with this. – mınxomaτ – 2015-10-07T18:44:17.283
Let us continue this discussion in chat.
– mbomb007 – 2015-10-07T18:45:05.653I take it there is no requirement for the final source code to be the same length as the initial source code? – trichoplax – 2015-10-09T11:37:47.737
@trichoplax Correct. Only the area of the source code needs to be different. Any memory locations that are outside the initial area do not matter. – mbomb007 – 2015-10-09T18:05:46.810
@mbomb007 I was thinking of answers that reduce the source code rather than expanding it. If the source code is reduced to zero does that still count since the memory no longer occupied by source code will then be occupied by something different? – trichoplax – 2015-10-09T18:08:12.567
@trichoplax Ah, yes. I think that's reasonable. – mbomb007 – 2015-10-09T18:18:17.657
Must the end result have the same amount of characters as the original source? – ericw31415 – 2016-04-27T09:43:20.770
No. My program in Self-modifying BF is an example of one that doesn't.
– mbomb007 – 2016-04-27T14:08:43.860