Last active
October 28, 2023 14:00
-
-
Save jvillste/dd83d5db01712ddd4171d58bd91f070f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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