CSES - Datatähti 2018 alku - Results
Submission details
Task:Fraktaali
Sender:FSMnArmosta
Submission time:2017-10-02 13:28:39 +0300
Language:Haskell
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED10
#2ACCEPTED10
#3ACCEPTED10
#4ACCEPTED10
#5ACCEPTED10
#6ACCEPTED10
#7ACCEPTED10
#8ACCEPTED10
#9ACCEPTED10
#10ACCEPTED10
Test results
testverdicttimegroup
#1ACCEPTED0.04 s1details
#2ACCEPTED0.05 s2details
#3ACCEPTED0.04 s3details
#4ACCEPTED0.03 s4details
#5ACCEPTED0.04 s5details
#6ACCEPTED0.05 s6details
#7ACCEPTED0.06 s7details
#8ACCEPTED0.06 s8details
#9ACCEPTED0.09 s9details
#10ACCEPTED0.27 s10details

Compiler report

input/code.hs:10:11: Warning:
    This binding for `flip' shadows the existing binding
      imported from `Prelude' at input/code.hs:1:1
      (and originally defined in `GHC.Base')

input/code.hs:14:1: Warning:
    Top-level binding with no type signature:
      line :: Int -> Int -> [Char]

input/code.hs:16:23: Warning:
    This binding for `y' shadows the existing binding
      bound at input/code.hs:14:6

input/code.hs:17:23: Warning:
    This binding for `y' shadows the existing binding
      bound at input/code.hs:14:6

input/code.hs:22:17: Warning:
    Defaulting the following constraint(s) to type `Integer'
      (Integral b0) arising from a use of `^' at input/code.hs:22:17
      (Num b0) arising from a use of `-' at input/code.hs:22:30
      (Read b0) arising from a use of `read' at input/code.hs:22:20-23
    In the expression: 2 ^ ((read num) - 1)
    In an equation for `side': side = 2 ^ ((read num) - 1)
    In the expression:
      do { num <- getLine;
           let sid...

Code

import Data.List

lowerRight :: Int -> Int -> Int -> Bool
lowerRight x y side = ((2*x `div` side) >= 1) && ((2*y `div` side) >= 1)

on :: (Int, Int) -> Int -> Bool
on (0, 0) 1 = False
on (x, y) 2 = lowerRight x y 2
on (x, y) side = if flip then not underlying else underlying
    where flip = lowerRight x y side
          halfside = side `div` 2
          underlying = on ((x `rem` halfside), (y `rem` halfside)) halfside

line y width = Data.List.intercalate "" (map (charFor) coords)
    where coords = [0..(width-1)] `zip` (Data.List.replicate width y)
          boolFor (x, y) = on (x, y) width
          charFor (x, y) = if boolFor (x, y) then "." else "#"

main :: IO ()
main = do
    num <- getLine
    let side = 2^((read num) - 1)
    let y = [0..(side-1)]
    let linewrap y = line y side
    let linelist = map (linewrap) y
    putStrLn (unlines linelist)

Test details

Test 1

Group: 1

Verdict: ACCEPTED

input
1

correct output
#

user output
#

Test 2

Group: 2

Verdict: ACCEPTED

input
2

correct output
##
#.

user output
##
#.

Test 3

Group: 3

Verdict: ACCEPTED

input
3

correct output
####
#.#.
##..
#..#

user output
####
#.#.
##..
#..#

Test 4

Group: 4

Verdict: ACCEPTED

input
4

correct output
########
#.#.#.#.
##..##..
#..##..#
####....
...

user output
########
#.#.#.#.
##..##..
#..##..#
####....
...

Test 5

Group: 5

Verdict: ACCEPTED

input
5

correct output
################
#.#.#.#.#.#.#.#.
##..##..##..##..
#..##..##..##..#
####....####....
...

user output
################
#.#.#.#.#.#.#.#.
##..##..##..##..
#..##..##..##..#
####....####....
...

Test 6

Group: 6

Verdict: ACCEPTED

input
6

correct output
##############################...

user output
##############################...

Test 7

Group: 7

Verdict: ACCEPTED

input
7

correct output
##############################...

user output
##############################...

Test 8

Group: 8

Verdict: ACCEPTED

input
8

correct output
##############################...

user output
##############################...

Test 9

Group: 9

Verdict: ACCEPTED

input
9

correct output
##############################...

user output
##############################...

Test 10

Group: 10

Verdict: ACCEPTED

input
10

correct output
##############################...

user output
##############################...