This file contains 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 sokoban.core) | |
(def moves {:n [0 1] :s [0 -1] :e [1 0] :w [-1 0]}) | |
(def start-world | |
{:person [3 1] | |
:targets #{[1 3]} | |
:crates #{[1 2]} | |
:blanks #{[1 3] [2 3] [3 3] | |
[1 2] [2 2] [3 2] |
This file contains 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
from random import randint | |
# A grid of the specified size, composed of random values in range [1,n] | |
def random_grid(size, n): | |
return [[randint(0, (n - 1)) for _ in range(size)] for _ in range(size)] | |
# Generate all sets of integers pairs in [0,n), excluding those of the form [a a] | |
def int_pairs(n): | |
pairs = [] | |
for i in range(0, n): |
This file contains 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 cluster.core) | |
; Begin by creating 'clusters' for all the squares of a particular number | |
; Then repeatedly check for adjacent clusters and merge them | |
(defn random-grid | |
"A grid composed of random values in range [1,n]" | |
[size n] | |
(vec (map vec | |
(partition size | |
(repeatedly (* size size) | |
#(int (+ 1.5 (rand (dec n))))))))) |
This file contains 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 different-int-pairs | |
"Generate all pairs of the integers [0,n), excluding those of the form [a,a] and only the first pair of the symmetric [a,b] [b,a]" | |
[n] | |
(mapcat (fn [x] (map #(vector x %) | |
(range (inc x) n))) | |
(range n))) |
This file contains 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 massive-arity | |
[& [a b c d e f g h i j k l m n o p q r s t u v w x y z]] | |
(print a b c d e f g h i j k l m n o p q r s t u v w x y z)) |
This file contains 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 vec-abs | |
[[x y]] | |
(+ (* x x) | |
(* y y))) | |
(defn vec-add | |
[x y] | |
(map + x y)) | |
(defn vec-sq |
This file contains 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 dijkstra.core) | |
(def edges {:A {:F 14 :C 9 :B 7} | |
:B {:A 7 :C 10 :D 15} | |
:C {:A 9 :B 10 :D 11 :F 2} | |
:D {:B 15 :C 11 :E 6} | |
:E {:D 6 :F 9} | |
:F {:A 14 :C 2 :E 9}}) | |
(def inf Integer/MAX_VALUE) |
This file contains 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 dijkstra.core) | |
(def initial-node {:score Integer/MAX_VALUE :route [] :dead? false}) | |
(defn make-initial-state [edges start-node] | |
(-> (zipmap (keys edges) (repeat initial-node)) | |
(assoc-in [start-node :score] 0) | |
(assoc-in [start-node :route] [start-node]))) | |
(defn live-nodes [state] |
This file contains 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
# Modified from http://repo.or.cz/w/anomen-overlay.git/tree/HEAD:/dev-java/maven-color | |
color_maven() { | |
local BOLD=`tput bold` | |
local TEXT_RED=`tput setaf 1` | |
local TEXT_GREEN=`tput setaf 2` | |
local TEXT_YELLOW=`tput setaf 3` | |
local RESET_FORMATTING=`tput sgr0` | |
$MAVEN_HOME/bin/mvn $@ | sed -e "s/\(\[INFO\]\ \-\-\-\ .*\)/${TEXT_BLUE}\1${RESET_FORMATTING}/g" \ | |
-e "s/\(\[INFO\]\ \[.*\)/${RESET_FORMATTING}\1${RESET_FORMATTING}/g" \ | |
-e "s/\(\[INFO\]\ \)\(BUILD SUCCESS\)/\1${TEXT_GREEN}\2${RESET_FORMATTING}/g" \ |
This file contains 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
[][$___=(($=(({}+"")))[$__=-~-~-~-~-~[]]+$[-~[]]+(""[+[]]+"")[-~[]]+(![]+"")[-~-~-~[]]+(($_=(!""+"")))[+[]]+$_[-~[]]+$_[-~-~[]]+$[$__]+$_[+[]]+$[-~[]]+$_[-~[]])][$___](($$=($_____=(!""+"")[-~[]]+(!""+"")[-~-~-~[]]+(!""+"")[+[]]+(!""+"")[-~-~[]]+(!""+"")[-~[]]+(""[+[]]+"")[-~[]] | |
)+"[][$___][$___]('"+$_____+"\"\\"+(""[+[]]+"")[+[]] | |
+(+[])+(+[]))+($$$=""+(-~-~-~-~[])+(-~[]))+($$$$="\"')()"))()+[][$___][$___]($$+($$$=-~$$$)+$$$$)()+[][$___][$___]($$+($$$=-~$$$)+$$$$)()+[][$___][$___]($$+($$$=-~$$$)+$$$$)() |