import Diagrams.Backend.SVG.CmdLine import Diagrams.Prelude hiding (parts) import Diagrams.TwoD.Layout.CirclePacking partsBy :: Int -> Int -> [[Int]] partsBy n k | k> n = [] | k == n = [[n]] | k < n = [k : p | i <- [0..k-1], p <- partsBy (n-k) (k-i)] parts :: Int -> [[Int]] parts n | n == 0 = [[]] | n> 0 = concat [partsBy n k | k <- [1..n]] syt :: Int -> [Int] -> [[[Int]]] syt n p | n == 0 = [[] | null p] | n> 0 = do (l,m,r) <- corners if m-1> 0 then do t <- syt (n-1) (l ++ [m-1] ++ r) let (tl, tm:tr) = splitAt (length l) t return (tl ++ (tm ++ [n]) : tr) else do t <- syt (n-1) l return (t ++ [[n]]) where h = length p zips = [(l,m,r) | i <- [0..h-1], let (l,m:r) = splitAt i p] corners = [(l,m,r) | (l,m,r) <- zips, null r || m> head r] all_syt :: Int -> [[[Int]]] all_syt n = [t | p <- parts n, t <- syt n p] count_syt :: Int -> Int count_syt = length . all_syt box :: Int -> Diagram B box x = (text (show x) # scale 0.8 # translateY (-0.0)) (unitSquare # bg gold # lw 0.3) tableauDiagram :: [[Int]] -> Diagram B tableauDiagram t = vcat [hcat [box x | x <- row] | row <- t] cake :: Diagram B cake = renderCirclePacking (approxRadius 16) [tableauDiagram t | t <- all_syt 6] `atop` (circle 38 # fc yellow # lc yellow ) `atop` (circle 38 # fc brown # lc brown # translateX 5 # translateY (-5)) bigtext :: String -> Diagram B bigtext s = text s # font "freemono" # fontSize (local 8) main = mainWith $ (vsep 5 [bigtext "Happy b^(5)(6)th birthday Doron!", cake, bigtext "(+1 for next year)"] # centerXY) (rect 170 80 # centerXY # lc white # fc white # bg white)

AltStyle によって変換されたページ (->オリジナル) /