ref: https://github.com/mame/radiation-hardened-quine
æ¾å°ç·ã¯ã¡ã¢ãªã¨ã©ã¼ãå¼ãèµ·ãããããã§ãããããªæ¾å°ç·ãé£ã³äº¤ãéé ·ãªç°å¢ã§ããã§ãããã¨ãªã Quine ãããã
ã¨ãããã¨ã§ãããã°ã©ã å ã® 1 æåãã©ã³ãã ã«æ¶ãã¦ãå ã®ããã°ã©ã ãåºåããããªãã¨ãããã¹ã㪠Quine ãæ¸ãã¾ããã*1
ä½ãè¨ã£ã¦ãããããããªãã¨æãã¾ããããããªãµãã«åããã®ã§ãã
# ã©ã³ãã ã« 1 æåæ¶ãã¹ã¯ãªãã $ cat mutate.rb src = $<.read src[rand(src.size), 1] = "" print src # rrquine.rb ããã©ã³ãã ã« 1 æåæ¶ããããã°ã©ã ãçæãã $ ruby mutate.rb rrquine.rb > broken.rb # å£ããããã°ã©ã ãå®è¡ãã (!) $ ruby broken.rb > rrquine2.rb # å ã«æ»ã (!!) $ diff rrquine.rb rrquine2.rb # ä¸è´ï¼
æ£ç´æ¸ãããããªãã¨æã£ã¦ã¾ãããããªãã¨æ¸ãã¦ãã¾ã£ããRuby æããããªããä»ã«æ¸ããè¨èªãããã ãããã*2
以ä¸ã³ã¼ãããã£ã¨è³¢ãæ¹æ³ããã£ããæãã¦ãã ããã(追è¨: GitHub のリポジトリãä½ã£ã¦ããã¾ããã)
eval='eval$q=%q(puts %q(10210/#{1 1 if 1==21}}/.i rescue##/ 1 1"[13,213].max_by{|s|s.size}#"##").gsub(/\d/){["=\47eval$q=%q(#$q)#\47##\47 ",:eval,:instance_,"||=9"][eval$&]} exit)#'##' instance_eval='eval$q=%q(puts %q(10210/#{1 1 if 1==21}}/.i rescue##/ 1 1"[13,213].max_by{|s|s.size}#"##").gsub(/\d/){["=\47eval$q=%q(#$q)#\47##\47 ",:eval,:instance_,"||=9"][eval$&]} exit)#'##' /#{eval eval if eval==instance_eval}}/.i rescue##/ eval eval"[eval||=9,instance_eval||=9].max_by{|s|s.size}#"##"
以ä¸ã¯æåã«å ¬éãããã¼ã¸ã§ã³ãã¨ããããåããã ãã®ãã®ãªã®ã§ããããæ±ãã
"%\ #{at_exit{eval'(eval q=%(s=%(B%A C{at_exit{ZGQG##G }}}ABB.rescue x rescue 42##B Z=GQG##G instance_Z=GQG##G Z Z if Z==instance_Z ).gsub ?Z,%[eval] 7.times{|n|s.gsub! (n+65).chr,(n<1?92:n+33).chr} puts s.gsub ?Q,%[(eval q=%(]+q+%[))#] $stdout.flush exit!0))#'##' }}}\"".rescue x rescue 42##" eval='(eval q=%(s=%(B%A C{at_exit{ZGQG##G }}}ABB.rescue x rescue 42##B Z=GQG##G instance_Z=GQG##G Z Z if Z==instance_Z ).gsub ?Z,%[eval] 7.times{|n|s.gsub! (n+65).chr,(n<1?92:n+33).chr} puts s.gsub ?Q,%[(eval q=%(]+q+%[))#] $stdout.flush exit!0))#'##' instance_eval='(eval q=%(s=%(B%A C{at_exit{ZGQG##G }}}ABB.rescue x rescue 42##B Z=GQG##G instance_Z=GQG##G Z Z if Z==instance_Z ).gsub ?Z,%[eval] 7.times{|n|s.gsub! (n+65).chr,(n<1?92:n+33).chr} puts s.gsub ?Q,%[(eval q=%(]+q+%[))#] $stdout.flush exit!0))#'##' eval eval if eval==instance_eval