aboutsummaryrefslogtreecommitdiff
path: root/src/distractionless/arithmetic_tasks.cljd
diff options
context:
space:
mode:
authorTim <contact@bytim.eu>2025-06-06 19:01:26 +0200
committerTim <contact@bytim.eu>2025-06-06 19:01:26 +0200
commitef29e1cde2265dfd26a276e6e75b5733981fefa7 (patch)
tree0596518302383c1178f98d2f9d0fb92af273dbe1 /src/distractionless/arithmetic_tasks.cljd
parentaca895de6901c01a7eeacaacc1d7f226d7c5e84e (diff)
downloaddistractionless-master.tar.xz
distractionless-master.zip
Replace countdown before starting specific apps with arithemtic tasksHEADmaster
Diffstat (limited to 'src/distractionless/arithmetic_tasks.cljd')
-rw-r--r--src/distractionless/arithmetic_tasks.cljd25
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)))))