In response to https://gist.github.com/jackrusher/5201340
Some observations about the entropy of bit sequences:
(seq-entropy '(0 0 0 0 1 1 1 1))
;; 1.0
(seq-entropy '(0 0 0 0))
;; 0.0
(ns amplifytest.core) | |
(defn headerval [str] | |
(let [intvals (map int (.getBytes str)) | |
len (count intvals) | |
v (reduce + (map-indexed (fn [i x] (* (Math/pow 26 (- len 1 i)) (- x 64))) intvals))] | |
(int v))) | |
(defn -main [& args] | |
(doseq [line (line-seq (java.io.BufferedReader. *in*))] |
<!DOCTYPE html> | |
<html lang="en" class="mdl-js"><head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="description" content="A front-end template that helps you build fast, modern mobile web apps."> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>Material Design Lite</title> | |
<!-- Add to homescreen for Chrome on Android --> | |
<meta name="mobile-web-app-capable" content="yes"> |
function Grid(M, N, mapFunction){ | |
this.grid = []; | |
this.M = M; | |
this.N = N; | |
if (M < 1 || N <1) throw new Error('Grid dimensions must be greater than 0'); | |
if (typeof mapFunction == 'function'){ | |
this.init(mapFunction); | |
} |
/** | |
* Creates a new Cart object, with an optional pricing parameter. | |
* @class | |
* @param {object} pricing | |
*/ | |
function Cart(prices){ | |
this.total = 0, | |
this.pricing = {}, | |
this.contents = {}; |
package katas.kata5; | |
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.Reader; | |
import java.security.MessageDigest; | |
import java.security.NoSuchAlgorithmException; | |
import java.util.BitSet; | |
public class BloomFilter { |
git config --global http.sslVerify false | |
npm config set strict-ssl false | |
~/.bowerrc | |
{ | |
"directory": "bower_components", | |
"registry": "http://bower.herokuapp.com", | |
"strict-ssl": false | |
} |
;; -*- emacs-lisp -*- | |
;; | |
;; The majority of this config is from Jack Rusher-- https://github.com/jackrusher/dotfiles | |
;; (Minor personal changes made by me -- @evanlh) | |
;; | |
;; I like my emacs to share as many behaviors as possible with OS | |
;; X and bash, to which end I've customized all three. | |
(require 'cl) ;; Common Lisp functions |
;; Begin Evan's attempt at section 11.3 | |
;; from http://www.doc.ic.ac.uk/~sgc/teaching/pre2012/v231/lecture11.html | |
(def examples | |
[{:weather :sunny, :parents :yes, :money :rich, :decision :cinema} | |
{:weather :sunny, :parents :no, :money :rich, :decision :tennis} | |
{:weather :windy, :parents :yes, :money :rich, :decision :cinema} | |
{:weather :rainy, :parents :yes, :money :poor, :decision :cinema} | |
{:weather :rainy, :parents :no, :money :rich, :decision :stayin} | |
{:weather :rainy, :parents :yes, :money :poor, :decision :cinema} | |
{:weather :windy, :parents :no, :money :poor, :decision :cinema} |
In response to https://gist.github.com/jackrusher/5201340
Some observations about the entropy of bit sequences:
(seq-entropy '(0 0 0 0 1 1 1 1))
;; 1.0
(seq-entropy '(0 0 0 0))
;; 0.0
;; Response to https://gist.github.com/jackrusher/5289206 | |
;; Fill in this definition of seq-entropy that takes a second | |
;; parameter that's the function that returns 'true' when a given item | |
;; is positive. | |
(defn seq-entropy | |
"Calculate the entropy of sequence 'sq' assuming the all positive | |
numbers represent positive samples." | |
[sq pos-func] | |
(let [len (count sq) |