Skip to content

Instantly share code, notes, and snippets.

Avatar

Janne Lemmetti jlemmett

  • DIAS Oy
  • Finland
View GitHub Profile
View keybase.md

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:

View 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 Dec 28, 2015
anyfailures-v2.clj
View 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*)]
@jlemmett
jlemmett / gist:7140649
Last active Dec 26, 2015
Annotated example solution to the problem of finding the largest multiple of consecutive five numbers from a long string of numbers, in Clojure.
View gist:7140649
;; 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 / gist:6883920
Last active Dec 24, 2015
Clojure-esimerkki tehtävästä "etsi suurin viiden peräkkäisen numeron tulo annetusta lukumerkkijonosta"
View gist:6883920
;; 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