Skip to content

Instantly share code, notes, and snippets.

View jlemmett's full-sized avatar

Janne Lemmetti jlemmett

  • DIAS Oy
  • Finland
View GitHub Profile
@jlemmett
jlemmett / gist:6883920
Last active December 24, 2015 23:59
Clojure-esimerkki tehtävästä "etsi suurin viiden peräkkäisen numeron tulo annetusta lukumerkkijonosta"
;; Apufunktio, joka muuttaa merkkijonoluvun numeeriseksi tyypiksi
(defn as-int [char]
(Character/getNumericValue char))
;; Funktio, joka palauttaa suurimman viiden peräkkäisen numeron tulon annetusta lukumerkkinonosta
(defn max-of-5-multiply-v1 [str] (apply max (map #(apply * %) (partition 5 1 (map as-int str)))))
;; Käyttöesimerkki
@jlemmett
jlemmett / gist:7140649
Last active December 26, 2015 10:59
Annotated example solution to the problem of finding the largest multiple of consecutive five numbers from a long string of numbers, in Clojure.
;; A helper function that converts a single character string into a numeric value
(defn as-int [char]
(Character/getNumericValue char))
;; The solution as a one-liner: function that returns the largest multiple of 5
;; consecutive digits in the given string of digits
(defn max-of-5-multiply-v1 [str]
(apply max (map #(apply * %) (partition 5 1 (map as-int str)))))
@jlemmett
jlemmett / anyfailures-v1.clj
Created November 13, 2013 18:52
anyfailures-v1.clj
;; Require lein-exec plugin so that we can run this as a standalone
;; script
;; Usage:
;; - 'lein exec anyfailures.clj' (looks for tests under ./test/system/results/
;; - 'lein exec anyfailures.clj foo' (looks for tests under ./foo/
(require 'leiningen.exec)
;; Add and require Enlive so we can parse HTML
(leiningen.exec/deps '[[enlive/enlive "1.1.4"]])
(require '[net.cgrand.enlive-html :as html])
@jlemmett
jlemmett / anyfailures-v2.clj
Last active December 28, 2015 05:59
anyfailures-v2.clj
(require 'leiningen.exec)
(leiningen.exec/deps '[[enlive/enlive "1.1.4"]])
(require '[net.cgrand.enlive-html :as html])
(defn result-file-loc
"Returns the location of the result files (either provided as the first
command line argument or a default value of 'test/system/results'"
[]
(let [first-cmd-line-arg (second *command-line-args*)]

Keybase proof

I hereby claim:

  • I am jlemmett on github.
  • I am jannel (https://keybase.io/jannel) on keybase.
  • I have a public key ASCcGtc5gKugQ5Lq3rR9j20cFTK6A6aJQ6OJOl-NNkwECQo

To claim this, I am signing this object: