Skip to content

Instantly share code, notes, and snippets.

View Macroz's full-sized avatar
⌨️
Programming

Markku Rontu Macroz

⌨️
Programming
View GitHub Profile
@Macroz
Macroz / keybase.md
Created November 19, 2019 15:02
Keybase

Keybase proof

I hereby claim:

  • I am macroz on github.
  • I am macroz (https://keybase.io/macroz) on keybase.
  • I have a public key ASCuYbAOYya7Q5CFpomYzrmKbQd-ssTXxh6pNmQ6KSBzGAo

To claim this, I am signing this object:

@Macroz
Macroz / brain.clj
Created March 20, 2014 07:34
Function for eating action in the cloud game
(defn eat [thinker world delta-time]
(let [cloud (rand-nth (find-touching-clouds world thinker))
amount (min (:size cloud)
(- configuration/life-maximum-size (:size thinker))
(* configuration/life-eat-amount delta-time))]
(-> world
(update thinker :action "eat")
(update thinker :size (+ (:size thinker) amount))
(update cloud :size (- (:size cloud) amount))
)))
@Macroz
Macroz / y-tunnus.clj
Created March 20, 2014 07:32
Validating the Finnish company identification Y-tunnus in Clojure
(ns misc.y-tunnus
(:use clojure.test)
(:import java.lang.Integer))
(defn valid? [code-with-checksum]
(when-let [[_ code checksum] (re-find #"(^\d{6,7})-(\d$)" code-with-checksum)]
(let [code (if (= 6 (count code))
(str "0" code)
code)
modulo (mod (->> (map str code)
@Macroz
Macroz / core.clj
Created March 19, 2014 16:51
Dijkstra's algorithm in Clojure
(ns dijkstra.core
(:require [clojure.string :as string])
(:use [clojure.data.priority-map])
(:use [clojure.test]))
(defn dijkstra [start goal?-fn distance-fn neighbors-fn max-depth]
(loop [open (priority-map [start [start]] 0)
depth 0]