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
''' | |
Implementation of the puzzle given at | |
https://worldspiritsockpuppet.com/2021/03/07/sleep-math-red-clay-blue-clay.html | |
I strongly suggest thinking about the puzzle for a while before looking at the | |
code; it's really interesting and counterintuitive, or was for me. | |
"Suppose that you have 1 kg of red clay that is 100 degrees and 1 kg of blue | |
clay that is 0 degrees. You can divide and recombine clay freely. If two pieces | |
of clay come into contact, temperature immediately equilibrates—if you put the |
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
shortname: ssc_archive | |
metadata: | |
dc: | |
title: SSC Archive | |
creator: Scott Alexander | |
language: en-US | |
tags: | |
title: h2 | |
content: | |
- "https://web.archive.org/web/20200217141740/https://slatestarcodex.com/2013/02/12/abraham-lincoln-ape-man/" |
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 archiver | |
(:require [clojure.string :as s])) | |
(def archive-root "https://web.archive.org/web/") | |
(def cutoff-date "20200621000000") | |
(def ssc-urls | |
"Assumes the existence of a file in the current directory named 'ssc-urls' and | |
containing a list of URLs, one per line." |
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 ski.wotcha | |
(:require [clojure.string :as string])) | |
;; Based on exercise at https://drive.google.com/drive/folders/1AQN08ikQZvq0QWn9KLuhiE9kJu1Tp2a5 | |
;;; NB: The top-level code to actually solve the problem is down at the bottom: | |
;; Clojure relies on Java regex, which means regexes of any | |
;; complexity are pretty ugly: | |
(def name-regex #"^(\p{IsAlphabetic}+), (\p{IsAlphabetic}+)") |
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 datapull | |
"Datomic-ish pull for vanilla Clojure data structures. Usage examples in test below." | |
(:require [clojure.test :as t])) | |
;; Alternatives: | |
;; - Juxt has a full-featured library for doing the same thing: https://github.com/juxt/pull | |
;; - Meander and Specter are both libraries for performing complex searches & transformations on Clojure data | |
(defn- seq-into | |
"Like into, but returns nil if existing-seq is empty or contains only nils." |
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
# stuff I had to do on a fresh Ubuntu 18.04 install (minimal IIRC) to get the learning-from-human-preferences project to work: | |
# ( https://github.com/mrahtz/learning-from-human-preferences ) | |
sudo apt install git | |
sudo apt install vim | |
mkdir bin | |
# Add /home/egg/bin and /home/egg/.local/bin to PATH | |
vim .bashrc | |
ln -s /usr/bin/python3 /home/egg/bin/python | |
python --version |
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 shors.core | |
(:require [clojure.math.combinatorics :as c] | |
[clojure.test :as t :refer [is deftest]])) | |
(def tries (atom 0)) | |
(defn test-val | |
"Given p - 1, check whether p is a factor of n. Returns q if it is." | |
[n p-1] | |
(swap! tries inc) |
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 tempdat | |
"Minimal example of an unexpected Datomic behavior" | |
(:require [datomic.api :as d])) | |
(def uri "datomic:mem://temp") | |
(d/delete-database uri) ; ensure fresh start | |
(d/create-database uri) | |
(def conn (d/connect uri)) |
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 cuber.core) | |
;; octal numbers: | |
(def start [0 1 2 3 4 5 6 7]) | |
(def end [4 2 4 2 4 2 4 2]) | |
(defn modding [f] | |
;; identity | |
(fn [x] (mod (f x) 8))) |
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
;; Declare namespace | |
(ns harmonium.sock-problem2 | |
(:require [clojure.pprint :refer [pprint]])) | |
;; ============ Starting here are some functions =========== | |
;; ============ for formatting output; feel free =========== | |
;; ============ to ignore. =========== | |
(defn to-percent [total n] |