Skip to content

Instantly share code, notes, and snippets.

main :: IO ()
main = do
part2_test
part2
part1 :: IO ()
part1 = do
input <- readFile "./aoc1_input"
let masses = map read . lines $ input
let fuel = map fuelRequired masses

Keybase proof

I hereby claim:

  • I am pranz on github.
  • I am pranz (https://keybase.io/pranz) on keybase.
  • I have a public key ASABatnUAA59a9_jZ3epyZmSrBMZffeIT2qSXRFIvp2Bdgo

To claim this, I am signing this object:

var gulp = require('gulp')
jade = require('gulp-jade')
babel = require('gulp-babel')
sass = require('gulp-sass')
concat = require('gulp-concat')
path = require('path');
paths = {
jade: './src/jade/**/*.jade',
sass: './src/sass/**/*.scss',
using System;
using System.Collections.Generic;
namespace Bingo
{
class MainClass
{
public static void Main (string[] args)
{
@Pranz
Pranz / for_tehnix
Created June 4, 2015 17:49
testpgp
-----BEGIN PGP MESSAGE-----
Version: GnuPG v2
hQIMA51LFjnuzpRqARAAhc0A3Nz+qNczZdN6oA3XmB0yzZ4Rsli7w+hR9gazlOBl
sFYPJQdtHte70EHznNb2Uhs9e+GxDBcq3rKlVrCSKEAGeohbbsJQZAw9/cqIhqi9
646IAEf4uBqC5xrFiio/8GBSfrjxHdD15GwiSHcB9r6c7toITNHv5pyA6YzpS5yf
6dLUjR+6EwSXUQ8jWC1TffqMv7z2JMlPYMo0b//JBrS/VRy3UOE+EJg3z5wJdNh1
83XtNKSMycNzCUNqn5lfQiQ0t5BdFODV5pFJ5y9tzqDMBM+5369ZVXXwj/oII6O9
zMY6CVEtcwHNyBTz7fYpH8Y/5frx2y7UnI/QQ2g6J3zb9bJm3rJclTBeIFhvofOH
7bMlFx3WGEvB55DZouXr/1b1tL74nBj2KILOS9UeaI96VmAopET9GkLs/VstkN/X

Keybase proof

I hereby claim:

  • I am pranz on github.
  • I am pranz (https://keybase.io/pranz) on keybase.
  • I have a public key whose fingerprint is 3609 8DFE 31C6 0B88 0884 E0ED 1045 7068 9F83 13D3

To claim this, I am signing this object:

module Raining where
waterVolume :: [Int] -> Int
waterVolume xs = water 0 0 [] xs
where water maxHeight accWater puddles [] = accWater
water maxHeight accWater puddles (x:xs)
| x >= maxHeight = water x (accWater + sum (map (flip subtract maxHeight) puddles)) [] xs
| null puddles = water maxHeight accWater [x] xs
| x > head puddles = let (waterFilled, rest) = break (>= x) puddles in water maxHeight (accWater + sum (map (flip subtract x) waterFilled)) ((waterFilled >> return x) ++ rest) xs
@Pranz
Pranz / ConstraintList
Last active August 29, 2015 13:56
List indexed by constraint
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleInstances #-}
data ConstraintList c where
Nil :: ConstraintList c
Cons :: (c a) => a -> ConstraintList c -> ConstraintList c
instance Show (ConstraintList Show) where
show Nil = "[]"
void filterM(bool (*f)(void*), List *ls){
List *xs = ls
while !f(xs->head) {
free(xs)
xs = xs->tail;
}
List *prev_node = xs;
for(List *i = xs->tail; i != NIL; i = i->tail){
if !f(i->head) {
free(i);