-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rb
More file actions
44 lines (38 loc) · 2.63 KB
/
Copy pathbuild.rb
File metadata and controls
44 lines (38 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
aa = <<~END
0111111111111111100000000000000000000000001111111000000000000000000000000000000000000000000000000000000000000000000000000001111110000000000000000000000011111100
0111111111111111111000000000000000000000001111111000000000000000000000000000001111111100000011111111100000000000000000000011111111000000000000000000000111111110
0111111111111111111110000000000000000000001111111000000000000000000000000000000111111100001111111110000000000000000000000000111100000000000000000000000001111000
0011111000000000111111001111111000111111101111111001111110001111110000001111110111111100111111111000000000111111111110000000000000000001111111001111110000000000
0111111000000000111111001111110000111111101111111111111111100111111000011111100111111101111111000000000011111111111111100001111111000111111111111111110011111110
0111111111111111111110001111110000111111001111111100011111110011111100111111000111111111111111100000000000111000001111110001111110001111111000011111100011111100
0111111111111111111000001111110000111111001111111000001111110001111110111110000111111111101111110000000011111111111111110001111110001111110000011111100011111100
0111111000011111100000001111111101111111001111111110111111110000111111111100000111111110001111111100000111111000111111110001111110000111111110111111100011111100
0111111000001111111000000111111111011111001111110111111111100000011111111000000111111100000011111111000111111111101111111101111111000011111111101111100011111110
0111111000000111111110000001111100011111101111100001111110000000001111110000001111111100000001111111110000111110000001111001111111000010000000011111100011111110
0000000000000000000000000000000000000000000000000000000000001111111111100000000000000000000000000000000000000000000000000000000000000111111111111111000000000000
0000000000000000000000000000000000000000000000000000000000000111111110000000000000000000000000000000000000000000000000000000000000001111111111111100000000000000
0000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000001111111110000000000000000
END
prefix="eval$s=%w"
postfix=".join"
aaa = aa.split("\n")
bits = aaa.join.reverse.to_i(2)
x = aaa.first.size
y = aaa.size
b = [Marshal.dump(bits)].pack("m")
main = <<~QUINE
n=Marshal.load("#{b}".unpack("m")[0])
e="eval$s=%w"<<39<<($s*3)
o=""
j=-1
0.upto(#{y}*#{x}-1){|i|
o<<((n[i]==1)?e[j+=1]:32)
o<<((i%#{x}==#{x-1})?10:"")
}
o[-22,6]=""<<39<<".join"
puts(o)
QUINE
quine = "%s'%s#'%s" % [prefix, main.split("\n").join(";").gsub(" ",""), postfix]
name = "quine.#{Time.now.to_i}.rb"
File.write(name, quine)
puts "ruby #{name}"