Start

heckmeck!

Nerd content and
cringe since 1999
Alexander Grupe
Losso/AttentionWhore

Quine Scarf

A “quine” is a program that outputs its own source code, without using any form of external input. This is a program that is not a quine (see below), but looks pretty when knitted into a scarf:

Photo by @fbz

This is not a traditional quine because:

  • It doesn’t print its own source code in text form, but as an image. That was the whole idea behind the quine scarf contest where this was handed in!
  • It cheats by reading its own source file – a no-go for proper quines!

However, it does avoid using image libraries and font files as external input. It comes with its own font and sets every pixel by hand. When run, the output looks like this:

Thanks a million to fbz for trying to send me a scarfed version of this, and no thanks to German customs who got suspicious about the package being a gift and sent it back to the US before I could resolve things… :(

To run it yourself, take the code and run:

perl quine.pl > quine.ppm

The .ppm can then be opened in Photoshop or Gimp. Contents of quine.pl:

   $/           
   =            
  "";           
   $P=          
   "P".         
    "1 ";       
     open       
      F,$0;     
       $P.=     
       "100".   
        " 12".  
        "00 ";  
         $P.=   
         "0 " x 
        120000; 
        @C=qw/  
      0000000000
      0000fa0000
      20c020c000
     28fe28fe28 
     2454d65448 
    c4c8102646  
    6c92720c12  
   0020c00000   
   007c828200   
  0082827c00    
 1054385410     
 10107c1010     
 00020c0000     
1010101010      
0006060000      
0408102040      
7c8a92a27c      
0242fe0202      
 468a929262     
 448292926c     
  182848fe08    
  e4a2a2a29c    
   3c5292920c   
   80808eb0c0   
    6c9292926c  
     6092929478 
     006c6c0000 
     006a6c0000 
      0010284400
      2828282828
      0044281000
      40809a9060
      7c829aaa78
     0e34c4340e 
     fe9292926c 
    7c82828244  
    fe82824438  
   fe92928282   
   fe90908080   
  7c8292945e    
 fe101010fe     
 0082fe8200     
 0c020202fc     
fe10284482      
fe02020202      
fe403040fe      
fe201008fe      
7c8282827c      
 fe90909060     
 7c828a847a     
  fe90989462    
  649292924c    
   8080fe8080   
   fc020202fc   
    e0180618e0  
     f8061806f8 
     c6281028c6 
     c0201e20c0 
      868a92a2c2
      00fe828200
      4020100804
      008282fe00
      2040804020
     0202020202 
     0000c02000 
    042a2a2a1e  
    fe2222221c  
   1c22222222   
   1c222222fe   
  1c2a2a2a18    
 107e909040     
 102a2a2a3c     
 fe1020201e     
0020be0000      
040222bc00      
fe08081422      
00fc020200      
3e2018201e      
 3e1020201e     
 1c2222221c     
  3f24242418    
  182424243f    
   3e10202018   
   122a2a2a24   
    20fc222200  
     3c0202043e 
     300c020c30 
      3c020c023c
      2214081422
      300a0a0a3c
      22262a3222
      10106c8282
      0000fe0000
     82826c1010 
     1020100810 
    54aa54aa54  
    /;$x=2;$y=  
    2; while(   
    ) {for   
   (split //)   
  { next if     
 /\n/;$J=ord    
 ($_)-32;$D=    
$C[$J];for(     
unpack("(A".    
"2)*",$D)){     
$T=1<<8;for     
($Z=0;$Z<8;     
 $Z++){$Q=      
 14+($x+($y     
 + $Z)*100)     
  *2;substr     
   ($P,$Q,1)=   
   "1" if(hex   
    $_)&$T;$T   
      >>=1;}    
       $x++;}   
       $x++;    
        if($x>  
        95){$x  
        =2;$y   
        +=8;}}  
        print   
         $P     
          ;     
         }      
previous next close
eie