Skip to content

Instantly share code, notes, and snippets.

@tompng

tompng/quine575.rb

Last active Dec 18, 2019
Embed
What would you like to do?
57577 quine
##5## ###7### ##5## ###7### ###7###
!eval s="$><< '!%sl s=%%p'% :eva%s"
code = File.read(__FILE__).lines[1].strip
File.write 'tmp.rb', code
out = `ruby tmp.rb`
counts = code.split.map(&:size)
puts
p out == code
p counts
raise unless out == code && counts == [5,7,5,7,7]
__END__
#
# x="x= %p;$><< x%%x"; $><< x%x
# x= "x= %p;$><< x%%x";$><< x%x
#
#
# x="=%p;$><<?x+x%%x";$><<?x+x%x
# x="=%p;$><<?x+x%%x";$><<?x+x%x
#
#
# x=%(x=%%(%s);$><<x%%x);$><<x%x
# x=%(x=%%(%s);$><<x%%x);$><<x%x
eval( s="$><< 'ev'+ +++'al( s=%p)'%s")
eval( s="$><< 'ev'+ +++'al( s=%p)'%s")
eval( s="$><< 'eva' '''''l( s=%p)'%s")
eval( s="$><< 'ev'+ +++'al( s=%p)'%s")
##5## ###7### ##5## ###7### ###7###8
;eval s="$><< ';%sl s=%%p'% 'eva'%s"
;eval s="$><< ';%sl s=%%p'% 'eva'%s"
;eval s="$><< ';%sl s=%p'%[ :eva,s]"
;eval s="$><< ';%sl s=%p'%[ :eva,s]"
;eval s="$><< ';%sl s=%p'%[ :eva,s]"
;eval s="$><< ';%sl s=%p'%[ :eva,s]"
eval( s="$><< 'eva' 'l(%cs= %p)'%s")
eval( s="t=+' s=%p' %s;$><< 'eval(+t+)'")
eval( s="puts 'eva' 'l(\x20 s=%p)'%s")
eval( s="puts 'eva' 'l(%s=%p)'%[' s',s]")
eval( s=%(puts 'eva' 'l( s=%('+s +'))'))
eval( s="puts 'eva' 'l(s=%('+s+'))'")
eval (s= %(puts 'eva' %(l(s=\#{s}))))
eval(s="$><< 'eva' 'l(s=%p )'%s" )
x
=%(x
=%%(%s)
$><<
x%%x)
$><<
x%x
12345 1234567 12345 1234567
;x=?'+ "x=?'+ =+ ++ %p; $>.<< x%%x"; $>.<< x%x
s="s=%p;puts(s%%s)";puts(s%s)
(s="")=~//;eval s
eval(s="$><< 'eva' 'l(s=%p )'%s" )
s="$><<'s=%p;eval(s)'%s"; eval(s)
s="$><<'s=%p; ev' 'al(s' ')'%s"; eval(s)
s="$> <<'s=%p; ev' 'al(s' ')'%s"; eval(s)
s=%($><<%(s=%(#{s});eval(s))); eval(s)
s=%($><<"s=%("+s+");eval(s)");eval(s)
s=%($><<"s=%("+s+");eval(s)");eval(s)
5555577777775555577777777777777
eval(s=%($><<"eval(s=%("+s+"))"))
eval( s=%($>. <<"ev al(s=%( "+s+"))"))
$>.<< %(
$>.<< %(
)*2,2
$>.<< <<22,2
222
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment