@@ -15,7 +15,7 @@ tags: [压缩包, Quine, 自产生程序, Quine Relay]
 
			
		
	
		
		
			
				
					
					  关于原理方面,先看[Will Greenberg ](https://github.com/wgreenberg )制作的一个[示例 ](https://wgreenberg.github.io/quine.zip/ ), , ( ) ( , ) , , 
  关于原理方面,先看[Will Greenberg ](https://github.com/wgreenberg )制作的一个[示例 ](https://wgreenberg.github.io/quine.zip/ ), , ( ) ( , ) , , 
 
			
		
	
		
		
			
				
					
					  这个问题看起来还挺复杂,不过在仓库的[Issues ](https://github.com/wgreenberg/quine.zip/issues/1 )就有人给出了几种解法(当然,这个题目解法不唯一),所以在理论上应该是可行的,那么接下来就需要研究压缩文件的格式来实现它了。   
  这个问题看起来还挺复杂,不过在仓库的[Issues ](https://github.com/wgreenberg/quine.zip/issues/1 )就有人给出了几种解法(当然,这个题目解法不唯一),所以在理论上应该是可行的,那么接下来就需要研究压缩文件的格式来实现它了。   
 
			
		
	
		
		
			
				
					
					## 实现ZIP Quine的探索 ## 实现ZIP Quine的探索  
			
		
	
		
		
			
				
					
					Russ Cox ](https://swtch.com/~rsc/ )写的[Zip Files All The Way Down ](https://research.swtch.com/zip )文章中, , , , , , , , : Russ Cox ](https://swtch.com/~rsc/ )写的《 [Zip Files All The Way Down ](https://research.swtch.com/zip )》 文章中, , , , , , , , :  
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					``` ```  
			
		
	
		
		
			
				
					
					 
			
		
	
		
		
			
				
					
					print 2
print 2
 
			
		
	
	
		
		
			
				
					
					
						
					 
					@@ -56,10 +56,10 @@ print 0
 
			
		
	
		
		
			
				
					
					  另外这个方案是针对使用基于LZ77与哈夫曼编码的DEFLATE压缩算法, , , ( ) , , , Matthew Barber ](https://github.com/honno )写了一篇很棒的[文章 ](https://github.com/honno/gzip-quine ), , 
  另外这个方案是针对使用基于LZ77与哈夫曼编码的DEFLATE压缩算法, , , ( ) , , , Matthew Barber ](https://github.com/honno )写了一篇很棒的[文章 ](https://github.com/honno/gzip-quine ), , 
 
			
		
	
		
		
			
				
					
					  还有一点, ? , , , , 
  还有一点, ? , , , , 
 
			
		
	
		
		
			
				
					
					  这么来看既然TGZ可以, ? , , , `repeat 64 64` 这样的指令能够满足要求, , , , , , , , , , , , , 
  这么来看既然TGZ可以, ? , , , `repeat 64 64` 这样的指令能够满足要求, , , , , , , , , , , , , 
 
			
		
	
		
		
			
				
					
					  虽然Russ Cox写的文章看起来做不到包含更多内容了, , , Ruben Van Mello ](https://github.com/ruvmello )写了一篇论文[A Generator for Recursive Zip Files ](https://www.mdpi.com/2076-3417/14/21/9797 ),在这篇论文里他不仅解决了包含的额外数据过少的问题,还编写了一个通用工具,能让普通人也能生成这样的压缩包,而且他还创新性的做了一种像衔尾蛇一样的双层嵌套循环压缩包,非常的有意思,所以接下来我打算试试他的方案。   
  虽然Russ Cox写的文章看起来做不到包含更多内容了, , , Ruben Van Mello ](https://github.com/ruvmello )写了一篇论文《 [A Generator for Recursive Zip Files ](https://www.mdpi.com/2076-3417/14/21/9797 )》 ,在这篇论文里他不仅解决了包含的额外数据过少的问题,还编写了一个通用工具,能让普通人也能生成这样的压缩包,而且他还创新性的做了一种像衔尾蛇一样的双层嵌套循环压缩包,非常的有意思,所以接下来我打算试试他的方案。   
 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					  在这篇论文中, , , , , , ( ) , , ( ) , , , ? , 
  在这篇论文中, , , , , , ( ) , , ( ) , , , ? , 
 
			
		
	
		
		
			
				
					
					## 制作一个嵌套循环的ZIP Quine ## 制作一个嵌套循环的ZIP Quine  
			
		
	
		
		
			
				
					
					, ( ) 在 接下来制作了一种循环压缩文件, , , , , , , , , ( ) , , , , , , , ,  
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					  另外既然这里面有两个压缩包, , , ( ) , , , ( ) ? , ? 
  另外既然这里面有两个压缩包, , , ( ) , , , ( ) ? , ? 
 
			
		
	
		
		
			
				
					
					  现在所有的理论都足够了, , Mabbs ](https://github.com/Mabbs/Mabbs.Project )吧, , ? , , , 
  现在所有的理论都足够了, , Mabbs ](https://github.com/Mabbs/Mabbs.Project )吧, , ? , , , 
 
			
		
	
		
		
			
				
					
					  接下来就该使用论文中提到的生成工具:[zip-quine-generator ](https://github.com/ruvmello/zip-quine-generator ), , , `--loop` ”参数就可以用这个程序创建嵌套循环的ZIP Quine了。不过它原本的代码不能修改里面生成的压缩包的名字, 压缩后的文件属性是隐藏文件 ](https://github.com/ruvmello/zip-quine-generator/blob/3b8cf977e7a93bb956ad966d5e3b4d503f410529/src/main/kotlin/zip/ZIPArchiver.kt#L845 ),还有[生成的压缩包中文件的创建时间总是当前时间 ](https://github.com/ruvmello/zip-quine-generator/blob/3b8cf977e7a93bb956ad966d5e3b4d503f410529/src/main/kotlin/zip/ZIPArchiver.kt#L29 ),以及[给文件内填充额外数据的代码里面填的是作者的声明 ](https://github.com/ruvmello/zip-quine-generator/blob/3b8cf977e7a93bb956ad966d5e3b4d503f410529/src/main/kotlin/zip/ZIPArchiver.kt#L30 ), , , , , `kotlinc src/main/kotlin -include-runtime -d output.jar` 就可以了, , , 
  接下来就该使用论文中提到的生成工具:[zip-quine-generator ](https://github.com/ruvmello/zip-quine-generator ), , , `--loop` ”参数就可以用这个程序创建嵌套循环的ZIP Quine了。不过它原本的代码不能修改里面生成的压缩包的名字, 压缩后的文件属性是隐藏文件 ](https://github.com/ruvmello/zip-quine-generator/blob/3b8cf977e7a93bb956ad966d5e3b4d503f410529/src/main/kotlin/zip/ZIPArchiver.kt#L845 ),还有[生成的压缩包中文件的创建时间总是当前时间 ](https://github.com/ruvmello/zip-quine-generator/blob/3b8cf977e7a93bb956ad966d5e3b4d503f410529/src/main/kotlin/zip/ZIPArchiver.kt#L29 ),以及[给文件内填充额外数据的代码里面填的是作者的声明 ](https://github.com/ruvmello/zip-quine-generator/blob/3b8cf977e7a93bb956ad966d5e3b4d503f410529/src/main/kotlin/zip/ZIPArchiver.kt#L30 ), , , , , `kotlinc src/main/kotlin -include-runtime -d output.jar` 就可以了, , , 
 
			
		
	
	
		
		
			
				
					
					
						
					 
					@@ -77,7 +77,7 @@ c = 'c = %r; print(c %% c)'; print(c % c)
 
			
		
	
		
		
			
				
					
					``` ```  
			
		
	
		
		
			
				
					
					 
			
		
	
		
		
			
				
					
					``` ```  
			
		
	
		
		
			
				
					
					  代码就像加了密似的, , 规范 ](http://www.lscheffer.com/malbolge_spec.html ),另外虽然这个语言写起来很复杂,但还是有人能用它编出程序的,甚至还有人用[Malbolge Unshackled ](https://esolangs.org/wiki/Malbolge_Unshackled )( ) Lisp解释器 ](https://github.com/iczelia/malbolge-lisp ),实在是恐怖如斯😨。   
  代码就像加了密似的,顺便一说这个执行的输出 结果是“Mayx”, 规范 ](http://www.lscheffer.com/malbolge_spec.html ),另外虽然这个语言写起来很复杂,但还是有人能用它编出程序的,甚至还有人用[Malbolge Unshackled ](https://esolangs.org/wiki/Malbolge_Unshackled )( ) Lisp解释器 ](https://github.com/iczelia/malbolge-lisp ),实在是恐怖如斯😨。   
 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					## 只能Quine的语言 ## 只能Quine的语言  
			
		
	
		
		
			
				
					
					, , , , ? , , : , , , , ? , , :  
			
		
	
		
		
			
				
					
					``` ```  
			
		
	
	
		
		
			
				
					
					
						
					 
					@@ -88,6 +88,9 @@ Hello, world!
 
			
		
	
		
		
			
				
					
					## Quine Relay的探索 ## Quine Relay的探索  
			
		
	
		
		
			
				
					
					( ) , , , , Yusuke Endoh ](https://github.com/mame )(这位还是[IOCCC ](https://www.ioccc.org/ )的冠军之一)创建的[quine-relay ](https://github.com/mame/quine-relay )项目, ( ) , , , , Yusuke Endoh ](https://github.com/mame )(这位还是[IOCCC ](https://www.ioccc.org/ )的冠军之一)创建的[quine-relay ](https://github.com/mame/quine-relay )项目,  
			
		
	
		
		
			
				
					
					  这种程序写起来会更复杂一些, , , ( ) , 维基百科 ](https://en.wikipedia.org/wiki/Quine_(computing )#Ouroboros_programs )之外,前段时间我还看到过一个不错的[文章 ](https://blog.mistivia.com/posts/2024-09-21-quine/ ), , , , quine-relay ](https://github.com/mame/quine-relay )项目中甚至还包含Brainfuck之类的esolang, , , 
  这种程序写起来会更复杂一些, , , ( ) , 维基百科 ](https://en.wikipedia.org/wiki/Quine_(computing )#Ouroboros_programs )之外,前段时间我还看到过一个不错的[文章 ](https://blog.mistivia.com/posts/2024-09-21-quine/ ), , , , quine-relay ](https://github.com/mame/quine-relay )项目中甚至还包含Brainfuck之类的esolang, , , 
 
			
		
	
		
		
			
				
					
					## Polyglot Quine的探索  
			
		
	
		
		
			
				
					
					, Polyglot ](https://en.wikipedia.org/wiki/Polyglot_(computing )) Quine, , , , , , , ( )  
			
		
	
		
		
			
				
					
					  Quine本身就已经很困难了, , , , 这段代码 ](https://github.com/TrAyZeN/polyglot-quine/blob/master/main.c )就是C和Python的Polyglot Quine, , , PyZipQuine ](https://github.com/d0sboots/PyZipQuine )项目, , , , 
 
			
		
	
		
		
			
				
					
					 
			
		
	
		
		
			
				
					
					# 感想 # 感想  
			
		
	
		
		
			
				
					
					, , , , , , , , , , , , , , , ,