Skip to content

Instantly share code, notes, and snippets.

#!/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
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 April 25, 2015 15:52
Solution to the Cheryl Birthday problem (based on Levent Erkok's solution)
-- 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 October 10, 2014 06:28
Script to switch swap Cabal sandboxes for different versions of GHC.
# 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 January 2, 2016 06:39
Ensure constraints are correct for testing for underflow/overflow for signed ints. Verified via SMT.
{-# 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 November 22, 2011 07:41
Odd behavior with stable names and type constraints.
-- 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 March 17, 2011 04:13
Sharing in a DSL
-- Lee Pike
-- Trying to understand sharing inside a DSL
-- BSD3
module MyDSL where
import Data.List
import Control.Monad.Reader
import Control.Monad.State
-- | 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.
--
#include <stdbool.h>
#include <stdint.h>
void CopilotSing();
extern struct { /* copilotStateCopilotSing */
struct { /* CopilotSing */
int32_t prophVal__idx[2];
bool playNote;
int32_t odd;
#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);