This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def numbers | |
[[" - " | |
"| |" | |
" " | |
"| |" | |
" - "] | |
[" " | |
" |" | |
" " |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns vice | |
(:require [clojure.spec :as s] | |
[clj-time.core :as t] | |
[clj-time.format :as tf]) | |
(:import [org.joda.time DateMidnight DateTime] | |
[java.util UUID] | |
[clojure.lang Keyword] | |
[java.math BigInteger] | |
[java.net URL URI] | |
[java.util.regex Pattern])) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set nocompatible | |
filetype off | |
set rtp+=~/.vim/bundle/Vundle.vim/ | |
call vundle#rc() | |
Plugin 'gmarik/Vundle.vim' | |
Bundle 'tpope/vim-classpath' | |
Bundle 'tpope/vim-leiningen' | |
Bundle 'tpope/vim-projectionist' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn merge-with-key | |
[f & maps] | |
(when (some identity maps) | |
(reduce (fn [acc x] | |
(reduce (fn [m [k v]] | |
(if (contains? m k) | |
(assoc m k (f k (get m k) v)) | |
(assoc m k v))) | |
acc | |
x)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{:starters | |
(["Marcus" 17] | |
["Baba" 16] | |
["Sami" 14] | |
["Tuomas" 14] | |
["Kabu" 14] | |
["Jesse" 11] | |
["Lydä" 9] | |
["Jonde" 9] | |
["Jebu" 9] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def vowels | |
#{\a \e \i \o \u}) | |
(defn count-vowels | |
[s] | |
(count (keep vowels (.toLowerCase s)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(fn best-hand | |
[hand] | |
(let [ranks (map second hand) | |
suits (map first hand) | |
rank-freqs (sort (vals (frequencies ranks)))] | |
(letfn [(flush? [hand] | |
(apply = suits)) | |
(straight? [hand] | |
(let [straight-hands (set (map set (partition 5 1 [\A \2 \3 \4 \5 | |
\6 \7 \8 \9 \T |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let positions x (arr: 'a []) = | |
let n = arr.Length - 1 | |
let idxs = [|0..n|] | |
Array.zip idxs arr | |
|> Array.filter (fun (_, v) -> v = x) | |
|> Array.map (fun (idx, _) -> idx) | |
positions 'b' [|'a';'b';'a';'a';'b'|] | |
// [|1; 4|] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns sudoku | |
(:require [clojure.set :as set])) | |
(defn row-values | |
[board [row _]] | |
(set (get board row))) | |
(defn- transpose | |
[matrix] | |
(vec (apply map vector matrix))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn map-matrix | |
[f colls] | |
(vec (map-indexed (fn [y row] | |
(vec (map-indexed (fn [x value] | |
(f value x y)) | |
row))) | |
colls))) |
NewerOlder