Skip to main content
even smaller!
Source Link

Haskell, 162 154 162 167 172 chars

import System.Random
main=(fmap g$randomRIOmain=randomRIO(1::Int,6))>>=putStrLn
g x=h++c odd:reverse h. where\x->let{h="-----\n|"++c(>1):' ':c(>3):"|\n|"++[c(>5)];c f|f x='o'|True=' '}in h++c odd:reverse h

It uses roughly the same idea as the Python one.

Readable version:

import System.Random

main = do
    x <- fmap render $ randomRIO (1 :: Int, 6)
    putStrLn (render x)

render x = str ++ check odd ++ reverse str
  where
    str = concat
        [ "-----\n|"
        , check (> 1)
        , " "
        , check (> 3)
        , "|\n|"
        , check (> 5)
        ]
    check f = if f x then "o" else " "

Haskell, 162 167 172 chars

import System.Random
main=(fmap g$randomRIO(1::Int,6))>>=putStrLn
g x=h++c odd:reverse h where{h="-----\n|"++c(>1):' ':c(>3):"|\n|"++[c(>5)];c f|f x='o'|True=' '}

It uses roughly the same idea as the Python one.

Readable version:

import System.Random

main = do
    x <- fmap render $ randomRIO (1 :: Int, 6)
    putStrLn x

render x = str ++ check odd ++ reverse str
  where
    str = concat
        [ "-----\n|"
        , check (> 1)
        , " "
        , check (> 3)
        , "|\n|"
        , check (> 5)
        ]
    check f = if f x then "o" else " "

Haskell, 154 162 167 172 chars

import System.Random
main=randomRIO(1::Int,6)>>=putStrLn. \x->let{h="-----\n|"++c(>1):' ':c(>3):"|\n|"++[c(>5)];c f|f x='o'|True=' '}in h++c odd:reverse h

It uses roughly the same idea as the Python one.

Readable version:

import System.Random

main = do
    x <- randomRIO (1 :: Int, 6)
    putStrLn (render x)

render x = str ++ check odd ++ reverse str
  where
    str = concat
        [ "-----\n|"
        , check (> 1)
        , " "
        , check (> 3)
        , "|\n|"
        , check (> 5)
        ]
    check f = if f x then "o" else " "
even smaller!
Source Link

Haskell, 167162 167 172 chars

import System.Random
main=(fmap g$randomRIO(1::Int,6))>>=putStrLn
g x=h++c odd++reverseodd:reverse h where{h=concat["h="-----\n|",c\n|"++c(>1),":' ",':c(>3),"|\n|",c:"|\n|"++[c(>5)];c f|f x="o"|True="x='o'|True=' "'}

It uses roughly the same idea as the Python one.

Readable version:

import System.Random

main = do
    x <- fmap render $ randomRIO (1 :: Int, 6)
    putStrLn x

render x = str ++ check odd ++ reverse str
  where
    str = concat
        [ "-----\n|"
        , check (> 1)
        , " "
        , check (> 3)
        , "|\n|"
        , check (> 5)
        ]
    check f = if f x then "o" else " "

Haskell, 167 172 chars

import System.Random
main=(fmap g$randomRIO(1::Int,6))>>=putStrLn
g x=h++c odd++reverse h where{h=concat["-----\n|",c(>1)," ",c(>3),"|\n|",c(>5)];c f|f x="o"|True=" "}

It uses roughly the same idea as the Python one.

Readable version:

import System.Random

main = do
    x <- fmap render $ randomRIO (1 :: Int, 6)
    putStrLn x

render x = str ++ check odd ++ reverse str
  where
    str = concat
        [ "-----\n|"
        , check (> 1)
        , " "
        , check (> 3)
        , "|\n|"
        , check (> 5)
        ]
    check f = if f x then "o" else " "

Haskell, 162 167 172 chars

import System.Random
main=(fmap g$randomRIO(1::Int,6))>>=putStrLn
g x=h++c odd:reverse h where{h="-----\n|"++c(>1):' ':c(>3):"|\n|"++[c(>5)];c f|f x='o'|True=' '}

It uses roughly the same idea as the Python one.

Readable version:

import System.Random

main = do
    x <- fmap render $ randomRIO (1 :: Int, 6)
    putStrLn x

render x = str ++ check odd ++ reverse str
  where
    str = concat
        [ "-----\n|"
        , check (> 1)
        , " "
        , check (> 3)
        , "|\n|"
        , check (> 5)
        ]
    check f = if f x then "o" else " "
Source Link

Haskell, 167 172 chars

import System.Random
main=(fmap g$randomRIO(1::Int,6))>>=putStrLn
g x=h++c odd++reverse h where{h=concat["-----\n|",c(>1)," ",c(>3),"|\n|",c(>5)];c f|f x="o"|True=" "}

It uses roughly the same idea as the Python one.

Readable version:

import System.Random

main = do
    x <- fmap render $ randomRIO (1 :: Int, 6)
    putStrLn x

render x = str ++ check odd ++ reverse str
  where
    str = concat
        [ "-----\n|"
        , check (> 1)
        , " "
        , check (> 3)
        , "|\n|"
        , check (> 5)
        ]
    check f = if f x then "o" else " "