Skip to content

Instantly share code, notes, and snippets.

@tlang0
tlang0 / coins.py
Last active July 21, 2019 22:12
Write a function that counts how many different ways you can make change for an amount of money, given an array of coin denominations. For example, there are 3 ways to give change for 4 if you have coins with denomination 1 and 2: 1+1+1+1, 1+1+2, 2+2.
combinations = []
amount = 12
def count_denoms(denoms, comb):
global combinations
for i in range(len(denoms)):
comb_new = comb + [denoms[i]]
if sum(comb_new) < amount:
count_denoms(denoms[i:], comb_new)
elif sum(comb_new) == amount:
@tlang0
tlang0 / obst.hs
Last active August 29, 2015 14:06
make files inaccessible by changing their names and parts of their contents (reversable).
import System.Environment
import System.Exit
import Control.Applicative
import Data.Bits (xor)
import System.IO
import System.Directory
import System.FilePath
import Control.Monad
import Crypto.Hash.SHA512 (hash)
import Data.Char
@tlang0
tlang0 / histeq.go
Last active December 20, 2015 03:58
A simple and inefficient histogram equalization program in Go1
/*
histeq - Histogram Equalizer
Copyright (C) 2012 wst <wstcode@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@tlang0
tlang0 / mergepdfs.sh
Last active October 11, 2015 11:48
merges pdfs
#!/bin/sh
#
# dependencies:
# - pdfmerge
#
# how to use:
# run this script where the pdfs are
# the files will be merged in order of their names
# replace spaces