Safe HaskellNone

Day03

Description

General - (AFAI can see) Hamler does not support streams/lazy lists (yet). Means for this one I will not use a data structure based approach, but will compute the solution :).

For that we will read the input and will build and array of lines that have the tree positions on it (let's call it a forrest).

I can then go into that forrest with my current position (x, y) and can check, if I am hitting a tree. Note: y needs to be modolo the line length.

Then I am repeating this n times (the number of lines in the input file) advancing m steps (3) to the right until I am done (and count the number of trees I am hitting on the way).

Part 1 - Doing the above.

Part 2 - Using part1 to do it for all given moves.

Synopsis

Documentation

type Coordinates = (Int, Int) #

data Forrest #

The forrest with all its trees.

Constructors

Forrest Int Int Trees 

Instances

Instances details
Eq Forrest # 
Instance details

Defined in Day03

Methods

(==) :: Forrest -> Forrest -> Bool

(/=) :: Forrest -> Forrest -> Bool

Show Forrest # 
Instance details

Defined in Day03

Methods

showsPrec :: Int -> Forrest -> ShowS

show :: Forrest -> String

showList :: [Forrest] -> ShowS

input :: String -> Forrest #

Read the input file.

part1 :: Forrest -> Coordinates -> Int #

Solve part1.

part2 :: Forrest -> Int #

Solve part2.