Skip to content

Instantly share code, notes, and snippets.

@andersk
Last active August 29, 2015 14:21
Show Gist options
  • Save andersk/2dd4874f6be306e63753 to your computer and use it in GitHub Desktop.
Save andersk/2dd4874f6be306e63753 to your computer and use it in GitHub Desktop.
Flowsnake
-- http://codegolf.stackexchange.com/questions/50521/ascii-art-of-the-day-2-flow-snakes
import Control.Applicative -- not needed in GHC 7.10
_#[0,0]=3
0#_=0
n#[a,b]=mod(div 0xf5bf9ae65b4000$4^(7*(n-1)#[div(s+3)7|s<-[3*a-b,a+2*b]]+mod(3*a-b)7))4
0%_=0
n%(c,d)=(n-1)%(2*c-d,c+3*d)+maximum(abs<$>[c,d,c+d])
f n=putStr$unlines[[" \\/ __"!!(2*n#[div a 2,b]+mod a 2)|a<-[b-n%(2,-1)+1..b+n%(2,-1)+fromEnum(n<3)]]|b<-[-n%(0,1)..n%(0,1)]]
main=f 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment