Skip to content

Instantly share code, notes, and snippets.

@jvillste
Last active October 28, 2023 14:00
Show Gist options
  • Save jvillste/dd83d5db01712ddd4171d58bd91f070f to your computer and use it in GitHub Desktop.
Save jvillste/dd83d5db01712ddd4171d58bd91f070f to your computer and use it in GitHub Desktop.
(ns experimentation.kertotaulu
(:require
[clojure.string :as string]))
(defn multiplications [numbers]
(mapcat (fn [a]
(for [b numbers]
[a b]))
numbers))
(comment
(doseq [table (partition-by first (->> (multiplications (range 1 11))
(map sort)
(distinct)))]
(println)
(doseq [[a b] table]
(println (str a " * " b " = " (* a b)))))
(do
(println (string/join "\t" (range 1 11)))
(println)
(doseq [number (range 1 101)]
(println (string/join "\t"
(for [maximum-multiplier (range 1 11)]
(str number
(when (contains? (->> (multiplications (range 1 (inc maximum-multiplier)))
(map (partial apply *))
(set))
number)
"*")))))))
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment