Last active
August 29, 2015 14:21
-
-
Save andersk/2dd4874f6be306e63753 to your computer and use it in GitHub Desktop.
Flowsnake
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
-- http://codegolf.stackexchange.com/questions/50521/ascii-art-of-the-day-2-flow-snakes | |
import Control.Applicative -- not needed in GHC 7.10 | |
(?)=div | |
(%)=mod | |
t[a,b]=[3*a+b,2*b-a] | |
_#[0,0]=0 | |
0#_=3 | |
n#p=[352,6497,2466,-1]!!((n-1)#t[(s+3)?7|s<-p])?(4^p!!0%7)%4 | |
0&_=0 | |
n&p=(n-1)&t p+maximum(abs<$>sum p:p) | |
n!b=n&[1,-b] | |
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]] | |
main=f 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment