Skip to content

Instantly share code, notes, and snippets.

View day6.py
#!/usr/bin/python
filepath = "input.txt"
def max_bounds(pts):
max_x = 0
max_y = 0
for x, y in pts:
if x > max_x: max_x = x
if y > max_y: max_y = y
View Lib.hs
module Lib where
import Control.Monad
import Language.Atom -- (bool, value, atom, E, Atom)
import Language.Atom.Elaboration (StateHierarchy(..))
genAtom :: IO ()
genAtom = do
let config = defaults --{ cRuleCoverage = False }
@leepike
leepike / Cheryl.hs
Created Apr 25, 2015
Solution to the Cheryl Birthday problem (based on Levent Erkok's solution)
View Cheryl.hs
-- Search solution in Haskell to the puzzle
--
-- See: http://www.nytimes.com/2015/04/15/science/a-math-problem-from-singapore-goes-viral-when-is-cheryls-birthday.html
--
-- Code modified from Levent Erkok's SBV solution
--
-- https://gist.github.com/LeventErkok/654a86a3ec7d3799b624
--
-- This code (like Levent's) is in the public domain.
--
@leepike
leepike / ghc-switch.sh
Created Oct 10, 2014
Script to switch swap Cabal sandboxes for different versions of GHC.
View ghc-switch.sh
# swith out a cabal sandbox for one version of a compiler for another.
#!/bin/bash
set -e
if [ -z "$2" ]; then
echo usage: $0 ghc-version-from ghc-version-to
exit 1
fi
@leepike
leepike / Bounded.hs
Last active Jan 2, 2016
Ensure constraints are correct for testing for underflow/overflow for signed ints. Verified via SMT.
View Bounded.hs
{-# LANGUAGE ScopedTypeVariables #-}
-- | Ensure constraints are correct for testing for underflow/overflow for
-- signed ints. Verified via SMT.
-- author : Lee Pike
-- date : Jan 2014
-- license: BSD3
--import Data.SBV.Bridge.CVC4
@leepike
leepike / Test.hs
Created Nov 22, 2011
Odd behavior with stable names and type constraints.
View Test.hs
-- Odd behavior using stable names: polymorphism with type constraints causes
-- non-termination (see the tests at the bottom).
module Test where
import System.Mem.StableName (StableName, makeStableName)
---------------------------------------------------------------------------------
type Map a = [StableName (Expr a)]
@leepike
leepike / MyDSL.hs
Created Mar 17, 2011
Sharing in a DSL
View MyDSL.hs
-- Lee Pike
-- Trying to understand sharing inside a DSL
-- BSD3
module MyDSL where
import Data.List
import Control.Monad.Reader
import Control.Monad.State
View IcsToRTM.hs
-- | Takes a .ics file (generated by iCal), finds all the incomplete TODO items,
-- and changes them into a format that can be imported into rememberthemilk.com (RTM).
-- via email
-- <http://www.rememberthemilk.com/help/answers/sending/emailinbox.rtm>.
-- Lee Pike <lee-pike-@gmail-.-com-> (remove dashes)
-- BSD3 License
--
-- NO WARRANTY : This program is incomplete and likely buggy. Your mileage my vary.
--
View CopilotSing.h
#include <stdbool.h>
#include <stdint.h>
void CopilotSing();
extern struct { /* copilotStateCopilotSing */
struct { /* CopilotSing */
int32_t prophVal__idx[2];
bool playNote;
int32_t odd;
View CopilotSing.c
#include <stdbool.h>
#include <stdint.h>
#include "WProgram.h"
int32_t notes[47] = {1519,1519,1519,1519,1519,1519,1519,1275,1915,1700,1519,1432,1432,1432,1432,1432,1519,1519,1519,1700,1700,1519,1700,1275,1519,1519,1519,1519,1519,1519,1519,1275,1915,1700,1519,1432,1432,1432,1432,1432,1519,1519,1275,1275,1432,1700,1915};
int32_t beats[47] = {1,1,2,1,1,2,1,1,1,1,4,1,1,1,1,1,1,2,1,1,1,1,2,2,1,1,2,1,1,2,1,1,1,1,4,1,1,1,1,1,1,2,1,1,1,1,4};
void playtone(int32_t , int32_t , int32_t);
You can’t perform that action at this time.