Skip to content

Instantly share code, notes, and snippets.

View GeoffRiley's full-sized avatar
😁
Keeping up with the Advent of Code so far

Geoff Riley GeoffRiley

😁
Keeping up with the Advent of Code so far
View GitHub Profile
@GeoffRiley
GeoffRiley / infiniteSequences.hs
Last active April 22, 2018 17:22
Haskell file containing some example infinite sequences
module InfiniteSequences(
evens,
odds,
triangles,
squares,
hexagonals,
power2,
power8,
power10,
power16,
@GeoffRiley
GeoffRiley / BinaryTree.hs
Created April 15, 2018 22:17
Haskell trial implementation of a binary tree, featuring two implementations of addNode for comparison.
data Tree = Leaf
| Node Int Tree Tree
deriving Show
--| Calculate the depth of the given tree
treeDepth :: Tree -> Int
treeDepth Leaf = 0
treeDepth (Node _ leftSubtree rightSubtree) =
1 + max (treeDepth leftSubtree) (treeDepth rightSubtree)
@GeoffRiley
GeoffRiley / fizzbuzz.hs
Last active April 14, 2018 00:36
My Haskell implementation of the FizzBuzz puzzle.
fizzBuzz :: IO ()
fizzBuzz = do
let fb = [fizzOrBuzz x | x <- [1..100]]
print fb
fizzOrBuzz :: Int -> String
fizzOrBuzz x
| x `mod` 15 == 0 = "FizzBuzz"
| x `mod` 3 == 0 = "Fizz"
| x `mod` 5 == 0 = "Buzz"