diff options
author | Tim <contact@bytim.eu> | 2025-06-06 19:01:26 +0200 |
---|---|---|
committer | Tim <contact@bytim.eu> | 2025-06-06 19:01:26 +0200 |
commit | ef29e1cde2265dfd26a276e6e75b5733981fefa7 (patch) | |
tree | 0596518302383c1178f98d2f9d0fb92af273dbe1 /src/distractionless/arithmetic_tasks.cljd | |
parent | aca895de6901c01a7eeacaacc1d7f226d7c5e84e (diff) | |
download | distractionless-master.tar.xz distractionless-master.zip |
Diffstat (limited to 'src/distractionless/arithmetic_tasks.cljd')
-rw-r--r-- | src/distractionless/arithmetic_tasks.cljd | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/distractionless/arithmetic_tasks.cljd b/src/distractionless/arithmetic_tasks.cljd new file mode 100644 index 0000000..e7357d9 --- /dev/null +++ b/src/distractionless/arithmetic_tasks.cljd @@ -0,0 +1,25 @@ +(ns distractionless.arithmetic-tasks) + +(def ^:private task-types [:addition :subtraction :multiplication]) + +(defn gen-task [] + {:type (rand-nth task-types) + :numbers [(inc (rand-int 20)) (inc (rand-int 20))]}) + +(defn- type->function [type] + (condp = type + :addition + + :subtraction - + :multiplication *)) + +(defn type->str [type] + (condp = type + :addition "+" + :subtraction "-" + :multiplication "*")) + +(defn test-result? [task input] + (= input + ((type->function (:type task)) + (first (:numbers task)) + (second (:numbers task))))) |