Skip to content

Instantly share code, notes, and snippets.

@finitud
Created February 28, 2012 20:10
Show Gist options
  • Save finitud/1934822 to your computer and use it in GitHub Desktop.
Save finitud/1934822 to your computer and use it in GitHub Desktop.
(ns boggle
(require [clojure.string :as str]))
(def words
(set (str/split-lines (slurp "brit-a-z.txt"))))
(defn select-words [s])
"Produces a list of words which start with 's'"
(filter #(.startsWith % s) words))
(defn board []
"Creates an 8x8 board full of randomly selected characters"
)
(defn inc-x [pos]
(cond
(nil? pos) nil
(= (mod pos 8) 7) nil
:else (inc pos)))
(defn dec-x [pos]
(cond
(nil? pos) nil
(= (mod pos 8) 0) nil
:else (dec pos)))
(defn inc-y [pos]
(cond
(nil? pos) nil
(> pos 55) nil
:else (+ pos 8)))
(defn dec-y [pos]
(cond
(nil? pos) nil
(< pos 8) nil
:else (- pos 8)))
(defn get-adjacents [pos]
(set [(dec-x pos)
(inc-x pos)
(dec-y pos)
(inc-y pos)
(inc-x (inc-y pos))
(inc-x (dec-y pos))
(dec-x (inc-y pos))
(dec-x (dec-y pos))
]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment