Код (я позволил себе немного упростить исходную формулу, предполагая, что x,y - целые):
main = putStrLn $ map f $ sequence [[0..16], [105,104 .. -1]]
where
f [y,-1] = '\n'
f [y,x] = if theTupper'sCondition x y
then '#'
else ' '
theTupper'sCondition x y = 1 == mod (n' `div` (2 ^ (17*x + y))) 2
where n' = div n 17
n :: Integer
n = read $ "96093937991895888497167296212785275471500433966012930665150551927"
++ "17028023952664246896428421743507181212671537827706233559932372808"
++ "74144307891325963941337723487857735749823926629715517173716995165"
++ "23289053822161240323885586618401323558513604882869333790249145422"
++ "92886670810961844960917051834540678277315517054053816273809676025"
++ "65625016981482083418783163849115590225610003652351370343874461848"
++ "37873723819822484986346503315941005497470059313833922649724946175"
++ "15457283667023697454610146559979337985374831437868418065934222278"
++ "98388722980000748404719"
Результат:
# # # ## # # # # # # # ## # # #
# # # # # # # # # # # # # # # # #
## # # # # ## # # # # # # ## #### ### ### # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # ### ### # # # # # # # # #
# # # # # # # ## # # # # # # # # ## # #
### # # # # # # # # # # # # # # # # # # # #
# # ## # ## ### # # # # ### ### # ### ### # # # # #
### # # # # # # # # # # # #### # # # # #
# # # # # # # # # # # # # # # #
## # # # # # ## ### # # # ## # #### #### # #
# # # # # # # # # #
# # # # # # # # # #
# # # # # # # # # #
### # # # # # # # #
# # # # # #
### # ### ### # ###
А что если так:
n = read $ "18534437474414146455176351878647649197207177870347453445110911485"
++ "53478406898621712689050950820843232698610899262648373062658096749"
++ "45848805789958210775561142487413932275220805681680066484692957053"
++ "00197360532127993431072009240461860667345312285868799011725966645"
++ "97395194503046958084606957203686710093810085659669757270284191173"
++ "35349918529704292645791571893578643503663432448768495013656948085"
++ "62615033293268365948691880076647951243334759409606362499412486255"
++ "92981759384485414189124719760356942075696610902355658962210688023"
++ "2902744632990892032"
?
1 comment:
readTemplate :: FilePath -> IO Integer
readTemplate file = readFile file >>= return . (*) 17 . convert . concat . map reverse . transpose . lines
where convert = foldl' (\r c -> if c == '#' then r*2+1 else r*2) 0
Post a Comment