Skip to content

Instantly share code, notes, and snippets.

@adampalay
adampalay / nqueens.py
Created August 17, 2018 19:36
8 queens problem in python
def n_queens(N, rows = None, arrangements = None):
if rows is None:
rows = N
if arrangements is None:
arrangements = []
if rows == 0:
return arrangements
@adampalay
adampalay / onePlusOne.hs
Last active June 19, 2018 16:30
today in 1 + 1 = 2 (with a reduction typeclass)
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE UndecidableInstances #-}
module Main where
main :: IO ()
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
module SkiTypes where
-- {-# OPTIONS_GHC -fno-warn-missing-methods #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MonoLocalBinds #-}
@adampalay
adampalay / publish.tla
Created May 18, 2018 16:35
Publish bug
------------------------------ MODULE publish ------------------------------
EXTENDS TLC, Sequences, Integers
(* --algorithm publish
variable draft_course = {1,2,3,4,5}, published_course \in SUBSET {1,2,3,4};
process modify \in {1, 2} \* two possibilities
variables local_draft = draft_course;
@adampalay
adampalay / quicksort.py
Created May 4, 2018 16:02
Quicksort in Python
import unittest
from hypothesis import given
from hypothesis import strategies as st
def quicksort(numbers):
if len(numbers) == 0:
return numbers
else:
first = numbers[0]
@adampalay
adampalay / quicksort.v
Created May 4, 2018 16:00
Quicksort in Coq
Require Import List.
Require Import Bool.
Require Import Arith.
Definition filter_lte (a: nat) list := filter (fun n=> n <=? a) list.
Definition filter_gt (a: nat) list := filter (fun n=> negb(n <=? a)) list.
Fixpoint quicksort (l: list nat) :=
match l with
nil => nil
@adampalay
adampalay / seq.py
Created August 21, 2017 21:24
538 Number Sequence
from __future__ import division, print_function
def ratio(length):
number_concurrent_3s = 0
the_two_we_are_before = 1
threes_that_should_be_before_this_two = {1: 3}
number_3s = 0
@adampalay
adampalay / shakespeare_names_with_z.ipynb
Created April 24, 2015 13:05
Shakespeare Names with Z
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.