Last active
January 25, 2020 19:06
-
-
Save tompng/d0da24e199e3fef37345312856e4e34d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
eval($a="def$_.+*;eval$c.join.to_i(2).digits(128).map(&:chr)*''end;$_")+ | |
----~~~~-~-~~~--~-~~~~~--~~~~~~--~-~-~--~~-~~-~~~~----~~--~~-~~---~-~--- | |
~--~-~----~~~-~~~~--~---~-~~~--~-~~-~-~---~--~-~----~~~~-~-~-~~~--~--~-- | |
-~-~--~-~-~~-~-~-~~~--~-~~-~~~---~-~~~~-~~~~---~-~-~~--~-~~~-~~-~~~-~--~ | |
~-~~~-~--~~~-~~~~~~-~~~~~-~~~~~-~~~----~-~~~-~~~~---~-~~~-~~~-~----~-~~~ | |
~~~-~~~-~-~~~-~--~~~~-~--~-~---~~--~--~~--~-~-~-----~~--~~~-~-~-~-~~--~- | |
-~~-~~-~-~----~-~-~-~~-~~~-~~~~---~-~~~-~~~-~-+++~-~~-~~~--~-~~-~~~-~~~~ | |
~~-~-~--~~~--~~~-~--~~-~~-~--~-~-~~~~-~-~---~~+++--~--~~-~~-~~~-~~--~~-- | |
-~-~~--++++++++++++++++++++~~~-~---~-~~~~--~-~+++~~-~~-~~~-~--~~~~--~~~~ | |
~-~~~~-++++++++++++++++++++-~~~~+++++++++++++++++++++++++++++++~~--~~~~- | |
-~~~~~-+++---~~~~-~-~~~-+++-~-~~+++++++++++++++++++++++++++++++~~~--~~~- | |
----~-~+++~~-~~--~--~~--+++~~~-~---~-~~~~--~-~+++~~-~~-~~~-~--~~~~--~~~- | |
~~~-~-~+++-~~-~~~----~~-+++---~~~~~-~~~~--~~~~+++~---~~~~--~~~~~-~-~~~~~ | |
-~~~~-~+++~--~~--~~-~~-~+++--~-~~~-~~-~----~~~+++~-~~~-~-~--~-~~~~-~-~-~ | |
~--~~-~+++~--~~--~~~-~-~+++-~-+++++++++++++++++++++++++++++++++++~~-~-~~ | |
-~--~--++++++++++++++++++++~~-+++++++++++++++++++++++++++++++++++-~-~-~- | |
~--~~~~++++++++++++++++++++~~-~~~-~----~~--~~-~--~-+++--~~~-~~~~----~-~- | |
-~-~~~~+++-~-~-~--~--~~-+++-~~~-~-~~~-~~--~--~~--~-+++~-~--~-~-~----~-~~ | |
-~~~-~-+++~--~-~~~--~-~-+++-~~~-~--~--~~~~-~--~~~~-+++--~~--~-~~~~~-~~~- | |
~~---~~+++--~~-~---~--~~+++~-~+++++++++++++++++++++++++++++++++~~~----~- | |
~--~-~~+++~~-~-~-~--~--~+++~--+++++++++++++++++++++++++++++++++~~~-~-~~~ | |
-~~--~-+++-~~--~-~-~--~-+++~-~-~-~~-~~-~~~-~-~--~-~+++~~--~-~--~~~-~--~- | |
-~~~~-~++++++++++++++++++++--~~~~---~~-+++-~-~~~~~-+++~~~----~-~-~-~~-~- | |
-~--~~-++++++++++++++++++++--~~~~-~----++++~~-~~--~+++--~~--~-~----~~--~ | |
~~~--~--~~-----~~--~~--~--~~--~--~---~~-++++~~~-~-~+++----~~-~---~~~~--~ | |
~~--~~~~--~--~~-~--~-~---~~~~~--~~~~~---~++++-~----+++-~~---~~~~-~~---~~ | |
-~~--~--~~--~-~~---~~--~~~~--~--~~-~--~~~-+++-~~--~+++--~~--~---~--~~-~~ | |
~-~-~----~~-~---~~~~--~~~--~~~~-~---~~-~--~-~---~~~+++~~--~~~~~---~-~--~ | |
-~~~~-~~~-~-~----~~-~---~~~~--~~~~-~~-~-~~--~~++++++++-~---~~-~--~-~--~~ | |
~-~-~----~~-~---~~~~--~~~--~~~~-~---~~-~~~~~~-~~++++++~--~-~~-~-~-~~~--~ | |
--~-~~~-~~~--~-~-~~-~--~~~~~~~~~--~-~~-~~-~--~--~-~~---~~-~~~-~-----~~~~ | |
~~~-~~----~~~--~~~~~--~~~~~----~~-~-~~~-~~-~~~~~-~-~-~-~~~--~-~~~--~-~-~ | |
~~~~~~-~~~-----~~~~-~-~~~--~-~~~~~--~~~~~~--~-~-~--~~-~~-~~~~----~~--~~- | |
~~---~-~---~--~--~---~~~-~~~~--~---~-~~~--~-~~-~-~---~--~--~---~~~~-~-~- | |
~~~--~--~---~-~--~-~-~~~--~-~~-~~~-------------------------------------- | |
eval($b="$c=[];def$c.~;$c<<1;end;def$c.-@;$c<<0;end;def$c.+@;$c;end;$c") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
prefix = <<CODE | |
eval($a="def$_.+*;eval$c.join.to_i(2).digits(128).map(&:chr)*''end;$_")+ | |
CODE | |
suffix = <<CODE | |
eval($b="$c=[];def$c.~;$c<<1;end;def$c.-@;$c<<0;end;def$c.+@;$c;end;$c") | |
CODE | |
code = File.read(__FILE__).split(/\n#CODE/).last | |
shape = <<SHAPE | |
------------------------------------------------------------------------ | |
------------------------------------------------------------------------ | |
------------------------------------------------------------------------ | |
------------------------------------------------------------------------ | |
------------------------------------------------------------------------ | |
----------------------------------------------+++----------------------- | |
----------------------------------------------+++----------------------- | |
-------++++++++++++++++++++-------------------+++----------------------- | |
-------++++++++++++++++++++-----+++++++++++++++++++++++++++++++--------- | |
-------+++--------------+++-----+++++++++++++++++++++++++++++++--------- | |
-------+++--------------+++-------------------+++----------------------- | |
-------+++--------------+++-------------------+++----------------------- | |
-------+++--------------+++-------------------+++----------------------- | |
-------+++--------------+++---+++++++++++++++++++++++++++++++++++------- | |
-------++++++++++++++++++++---+++++++++++++++++++++++++++++++++++------- | |
-------++++++++++++++++++++------------------------+++------------------ | |
-------+++--------------+++------------------------+++------------------ | |
-------+++--------------+++------------------------+++------------------ | |
-------+++--------------+++---+++++++++++++++++++++++++++++++++--------- | |
-------+++--------------+++---+++++++++++++++++++++++++++++++++--------- | |
-------+++--------------+++------------------------+++------------------ | |
-------++++++++++++++++++++------------+++---------+++------------------ | |
-------++++++++++++++++++++------------++++--------+++------------------ | |
----------------------------------------++++-------+++------------------ | |
-----------------------------------------++++------+++------------------ | |
------------------------------------------+++------+++------------------ | |
---------------------------------------------------+++------------------ | |
----------------------------------------------++++++++------------------ | |
------------------------------------------------++++++------------------ | |
------------------------------------------------------------------------ | |
------------------------------------------------------------------------ | |
------------------------------------------------------------------------ | |
------------------------------------------------------------------------ | |
------------------------------------------------------------------------ | |
SHAPE | |
width = 72 | |
height = shape.lines.size | |
code = code.delete($/) | |
n = 0; code.chars.reverse_each { |c| n = n * 128 + c.ord } | |
bits = n.to_s(2).chars | |
output = prefix + shape.gsub('-'){ bits.pop == '1' ? '~' : '-'} + suffix | |
File.write 'unary_clock.rb', output | |
puts output | |
exit | |
#CODE | |
puts'eval($a="'+$a+'")+'; | |
t=Time.now; | |
h=t.hour%12*0.52+(m=t.min/9.6)/12; | |
34.times{|y| | |
puts 72.times.map{|x| | |
z=36i-x.i+33.5-2*y; | |
a,b=(z*2.72**h.i).rect; | |
c,d=(z*2.72**m.i).rect; | |
(-2<a&&a<20&&b.abs<2)||(0<c&&c<29&&d.abs<1)||(z.abs-31).abs<1?'+':'-~'[$c.pop||0] | |
}*''}; | |
puts'eval($b="'+$b+'")'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
`ruby unary_clock_generator.rb` | |
def reset | |
$a = $b = $c = nil | |
$output = '' | |
end | |
def Time.now | |
$time | |
end | |
def bits(code) | |
(code.lines.grep(/^[-+~]+$/).join.delete("+\n")+'-'*9999)[0,9999] | |
end | |
CODE = File.read 'unary_clock.rb' | |
BITS = bits CODE | |
$output = '' | |
def puts(output) | |
$output << output << $/ | |
end | |
def test_time hour, min, show: false | |
$time = Time.new(1, 1, 1, hour, min) | |
eval CODE | |
output = $output | |
reset | |
raise unless CODE.lines[0] == output.lines[0] | |
raise unless CODE.lines[-1] == output.lines[-1] | |
raise unless BITS == bits(output) | |
if show | |
p [hour, min] | |
$><< output | |
end | |
end | |
24.times{ |h| | |
60.times { |m| | |
test_time h, m | |
} | |
test_time h, rand(60), show: true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment