Skip to content

Instantly share code, notes, and snippets.

;; ummels's solution to Palindromic Numbers
;; https://4clojure.com/problem/150
(fn [n]
(letfn [(decode [n] (if (< n 10) [n] (conj (decode (quot n 10)) (rem n 10))))
(encode [x] (reduce #(+ (* % 10) %2) 0 x))
(next-pal [n]
(let [N (decode n)
l (count N)
d (quot l 2)
@ummels
ummels / dijkstra.clj
Last active March 27, 2024 07:33
Dijsktra's shortest-path algorithm in Clojure
(require '[clojure.data.priority-map :refer [priority-map]])
(defn map-vals [m f]
(into {} (for [[k v] m] [k (f v)])))
(defn remove-keys [m pred]
(select-keys m (filter (complement pred) (keys m))))
(defn dijkstra
"Computes single-source shortest path distances in a directed graph.
@ummels
ummels / mydiss.cls
Last active March 27, 2024 14:56
Class file for my PhD thesis
% Copyright (c) 2010 Michael Ummels <michael@ummels.de>
%
% Permission to use, copy, modify, and/or distribute this software for any
% purpose with or without fee is hereby granted, provided that the above
% copyright notice and this permission notice appear in all copies.
%
% THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
% WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
% MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
% ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES