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
<?php | |
/** | |
* A few notes on this code. | |
* | |
* First, I installed PHPUnit via composer to run the tests. This is the reason for the | |
* require_once. | |
* | |
* Second, I made this all one file (multiple classes) in order to make it easier to | |
* post to a gist. Normally, of course, I'd have separate paths/files for different | |
* classes. If you put this all into one file to check/run with phpunit, you'll need to |
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
(ann get-number-of-cleared-spaces | |
[(IPersistentVector (IPersistentVector Any)) | |
-> | |
AnyInteger]) | |
(defn get-number-of-cleared-spaces | |
"Returns the number of cleared spaces in the grid." | |
[grid] | |
(inc (reduce (fn> [[cleared :- AnyInteger] | |
[row :- (IPersistentVector Any)]] | |
(let [result (inc (reduce (fn> [[row-cleared :- AnyInteger] |
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
(ann zero-path-between | |
[(IPersistentVector (IPersistentVector Any)) Symbol (Vector* Number Number) | |
(Vector* Number Number) | |
-> | |
(IPersistentVector (IPersistentVector Any))]) | |
(defn zero-path-between | |
"Traverses the path between start and end and changes each position to 0." | |
[grid direction start end] | |
(let [next (get-next-coordinate grid start direction)] | |
(if (and next (not= next end)) |
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 greed.coords | |
(:require [clojure.core.typed :refer [ann]])) | |
(ann get-next-coordinate-northeast | |
[NonEmptySeqable (Option Number) (Option Number) -> (Option (IPersistentList Number))]) | |
(defn get-next-coordinate-northeast [grid x y] | |
(when-not (or (nil? x) (nil? grid) (>= x (- (count (first grid)) 1)) | |
(nil? y) (<= y 0)) | |
(list (+ x 1) (- y 1)))) |
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 set-thing-at-grid-position [grid position thing] | |
"Sets the position of grid to THING, then returns the new grid." | |
(let [x (first position) | |
y (nth position 1)] | |
(into (conj (subvec grid 0 y) | |
(into (conj (subvec (first (subvec grid y (inc y))) 0 x) | |
thing) | |
(subvec (first (subvec grid y (inc y))) (inc x)))) | |
(subvec grid (inc y))))) |
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
;; GRID is a vector of vectors that represents a game board | |
;; Example: | |
;; [[1 3 4 9 5] [5 1 2 4 7] [1 "@" 0 0 5] [4 2 3 9 1] [1 2 3 4 5]] | |
;; should print out | |
;; 13495 | |
;; 51247 | |
;; 1@ 5 | |
;; 42391 | |
;; 12345 | |
;; |
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
on findTurntableTab() | |
set AppleScript's text item delimiters to "/" | |
set foundTab to "no" | |
tell application "Google Chrome" | |
set theWindows to get every window | |
repeat with theWindow in theWindows | |
repeat with theTab in every tab in theWindow | |
set theURL to URL of theTab | |
set baseURL to text item 3 of theURL |
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
$ brew --config | |
HOMEBREW_VERSION: 0.9.2 | |
HEAD: 2814e3a9fa88acf262062a26af15d87dc9f572d6 | |
HOMEBREW_PREFIX: /usr/local | |
HOMEBREW_CELLAR: /usr/local/Cellar | |
CPU: 8-core 64-bit sandybridge | |
OS X: 10.8-x86_64 | |
Xcode: 4.4 | |
CLT: 4.4.0.0.1.1249367152 | |
GCC-4.0: N/A |
NewerOlder