From ef29e1cde2265dfd26a276e6e75b5733981fefa7 Mon Sep 17 00:00:00 2001 From: Tim Date: Fri, 6 Jun 2025 19:01:26 +0200 Subject: Replace countdown before starting specific apps with arithemtic tasks --- src/distractionless/arithmetic_tasks.cljd | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/distractionless/arithmetic_tasks.cljd (limited to 'src/distractionless/arithmetic_tasks.cljd') 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))))) -- cgit v1.2.3