Skip to content

Instantly share code, notes, and snippets.

View egri-nagy's full-sized avatar

Attila Egri-Nagy egri-nagy

View GitHub Profile
@camsaul
camsaul / make_change.clj
Last active April 18, 2023 09:23
Make change (core.logic) with lots of comments
(ns make-change
(:refer-clojure :exclude [==])
(:require [clojure.core.logic :refer :all]
[clojure.core.logic.fd :as fd]))
(def common-us-coins
{:penny 1
:nickel 5
:dime 10
:quarter 25})
@lqhl
lqhl / arXiv-package.sh
Created August 12, 2016 03:30
Make arXiv compatible submission
#!/bin/bash
# arXiv uses an outdated TexLive distribution. This script is used to package
# all neccesary files so my paper can be compiled on arXiv...
# path to the texlive distribution
TEXLIVE=/usr/local/texlive/2016
# prepare the diretory for my submission
rm arXiv-package.zip
@Janiczek
Janiczek / klondike.clj
Created January 27, 2014 17:52
Core.logic solutin for "Klondike" puzzle
;; core.logic solution for "Klondike" puzzle:
;; http://www.futilitycloset.com/2014/01/27/back-from-the-klondike/
;; unfortunately, on the real problem it dies with OutOfMemoryError.
;; but theoretically it works :)
(ns klondike.core
(:refer-clojure :exclude [== !=])
(:require [clojure.core.logic :refer [run == != fresh appendo conde all fail project]]
[clojure.core.logic.fd :as fd]))
@t2ru
t2ru / core.clj
Created October 12, 2013 06:32
ClojureでSEND+MORE=MONEYを解いた ref: http://qiita.com/t2ru/items/b47da0ebcf04ec551312
(ns smm.core
(:refer-clojure :exclude [==])
(:use [clojure.core.logic])
(:require [clojure.core.logic.fd :as fd]))
;;; S E N D
;;; + M O R E
;;; ---------
;;; M O N E Y
@cgrand
cgrand / tarjan.clj
Last active November 18, 2020 03:08
Implementing Tarjan in Clojure, step by step
;; Now, replace the loop by more telling operations.
(defn tarjan
"Returns the strongly connected components of a graph specified by its nodes
and a successor function succs from node to nodes.
The used algorithm is Tarjan's one."
[nodes succs]
(letfn [(sc [env node]
; env is a map from nodes to stack length or nil, nil means the node is known to belong to another SCC
; there are two special keys: ::stack for the current stack and ::sccs for the current set of SCCs