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
# This program solves a puzzle I encountered recently. | |
# The puzzle consists of four cubes, each face of which has one of four colours. | |
# The objective is to arrange them in a column so that, looking down each side | |
# of the column, the four visible colours are all different. | |
require 'pp' | |
require 'set' | |
# A cube with colours attributed to its faces. | |
class Cube |
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
; Burrows-Wheeler Transform (and inverse) | |
; http://en.wikipedia.org/wiki/Burrows%E2%80%93Wheeler_transform | |
(def string-start \u0098) | |
(defn bwt [s] | |
(map last | |
(sort-by vec | |
(take (inc (count s)) | |
(iterate #(concat (rest %) |
NewerOlder