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| 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 { |
| ;; 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) |
| ;; Homework III | |
| ;; first, some useful functions from the standard library... | |
| (frequencies [1 2 1 2 1 2 3 4 2 3 4 5]) | |
| ;; => {1 3, 2 4, 3 2, 4 2, 5 1} | |
| ;; a convenience function that returns a map from each value in the | |
| ;; input to the count of its occurence | |
| ;; Evan, here's the python equivalent: |
| (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 = {}; |
| git config --global http.sslVerify false | |
| npm config set strict-ssl false | |
| ~/.bowerrc | |
| { | |
| "directory": "bower_components", | |
| "registry": "http://bower.herokuapp.com", | |
| "strict-ssl": false | |
| } |