A robust quine program that works even after any one character is deleted.
The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:
This is a robust self-printing program written in Ruby. It works even if you delete one character anywhere from the code.
rquine.rband check if the output is equal to the original code:
$ ruby rquine.rb > rquine2.rb $ diff rquine.rb rquine2.rb
Prepare a script that deletes one character randomly:
$ cat mutate.rb src = ARGF.read src[rand(src.size), 1] = "" print src
Generate a broken program by deleting one character from
$ ruby mutate.rb rquine.rb > broken.rb
Run the broken program:
$ ruby broken.rb > rquine2.rb
You will see the output exactly equal to the original code:
$ diff rquine.rb rquine2.rb
old-rquine.rbis the first version based on a trivial redundancy approach (having two copies of the main code).
flagitious.rbis the smarter version that repairs itself instead of redundancy. It was created by Darren Smith aka. flagitious. Thank you flagitious! (Note that this version only works with 1.8.7.)
rquine.rbis the latest "ascii-art" version based on flagitious's approach. It works with 1.9 or later.
Copyright (c) 2014 Yusuke Endoh (@mametter), @hirekoke
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.