Search Results
6/17/2025, 12:08:02 AM
Microsoft wins again ;^)
main :: IO ()
main = mapM_ putStrLn (triangle 10 10 2)
triangle :: Int -> Int -> Int -> [String]
triangle base height thickness =
[ row y | y <- [0 .. height - 1] ]
where
row y
| y < thickness = replicate (base - 1 - y) ' ' ++ replicate (2 * y + 1) '*'
| y < height - thickness = replicate (base - 1 - y) ' ' ++ "*" ++ replicate (2 * y - 1) ' ' ++ "*"
| otherwise = replicate (2 * base - 1) '*'
main :: IO ()
main = mapM_ putStrLn (triangle 10 10 2)
triangle :: Int -> Int -> Int -> [String]
triangle base height thickness =
[ row y | y <- [0 .. height - 1] ]
where
row y
| y < thickness = replicate (base - 1 - y) ' ' ++ replicate (2 * y + 1) '*'
| y < height - thickness = replicate (base - 1 - y) ' ' ++ "*" ++ replicate (2 * y - 1) ' ' ++ "*"
| otherwise = replicate (2 * base - 1) '*'
Page 1