fork download
  1. stringCircle :: String -> String
  2. stringCircle str =
  3. unlines [[ maybe ' ' id $ lookup (x,y) ps | x <- [-2*ri..2*ri]] | y <- [-ri..ri]]
  4. where
  5. ri = length str `div` 3
  6. ps = zipWith f [0..] str
  7. f i c = ((round $ 2 * r * cos t, round $ r * sin t), c)
  8. where
  9. t = i / fromIntegral (length str) * 2 * pi - pi / 2
  10. r = fromIntegral ri :: Double
  11.  
  12. main :: IO ()
  13. main = putStrLn $ stringCircle "子丑寅卯辰巳午未申酉戌亥"
  14.  
Success #stdin #stdout 0s 6288KB
stdin
Standard input is empty
stdout
        子        
    亥       丑    
 戌             寅 
                 
酉               卯
                 
 申             辰 
    未       巳    
        午