fork(2) download
  1. -- http://c...content-available-to-author-only...e.com/questions/50521/ascii-art-of-the-day-2-flow-snakes
  2.  
  3. import Control.Applicative -- not needed in GHC 7.10
  4.  
  5. (?)=div
  6. (%)=mod
  7. t[a,b]=[3*a+b,2*b-a]
  8. _#[0,0]=0
  9. 0#_=3
  10. n#p=[352,6497,2466,-1]!!((n-1)#t[(s+3)?7|s<-p])?(4^p!!0%7)%4
  11. 0&_=0
  12. n&p=(n-1)&t p+maximum(abs<$>sum p:p)
  13. n!b=n&[1,-b]
  14. f n=putStr$unlines[["__ \\/ "!!(2*n#t[a?2,-b]+a%2)|a<-[b-n!2+1..b+n!2+0^n?3]]|b<-[-n!0..n!0]]
  15.  
  16. main=getLine>>=f.read
Success #stdin #stdout 0s 4620KB
stdin
3
stdout
                 ____                   
            ____ \__ \                  
            \__ \__/ / __               
            __/ ____ \ \ \    ____      
           / __ \__ \ \/ / __ \__ \     
      ____ \ \ \__/ / __ \/ / __/ / __  
 ____ \__ \ \/ ____ \/ / __/ / __ \ \ \ 
 \__ \__/ / __ \__ \__/ / __ \ \ \ \/   
 __/ ____ \ \ \__/ ____ \ \ \ \/ / __   
/ __ \__ \ \/ ____ \__ \ \/ / __ \/ /   
\ \ \__/ / __ \__ \__/ / __ \ \ \__/    
 \/ ____ \/ / __/ ____ \ \ \ \/ ____    
    \__ \__/ / __ \__ \ \/ / __ \__ \   
    __/ ____ \ \ \__/ / __ \/ / __/ / __
   / __ \__ \ \/ ____ \/ / __/ / __ \/ /
   \/ / __/ / __ \__ \__/ / __ \/ / __/ 
   __/ / __ \ \ \__/ ____ \ \ \__/ / __ 
  / __ \ \ \ \/ ____ \__ \ \/ ____ \/ / 
  \ \ \ \/ / __ \__ \__/ / __ \__ \__/  
   \/ / __ \/ / __/ ____ \ \ \__/       
      \ \ \__/ / __ \__ \ \/            
       \/      \ \ \__/ / __            
                \/ ____ \/ /            
                   \__ \__/             
                   __/