From 622761017ca37db1f25a4b08957d199d7e720212 Mon Sep 17 00:00:00 2001 From: elioat Date: Thu, 13 Jul 2023 09:42:47 -0400 Subject: * --- janet/tmplt/src/app.janet | 19 ++----------------- janet/tmplt/test/sum.janet | 2 +- 2 files changed, 3 insertions(+), 18 deletions(-) (limited to 'janet/tmplt') diff --git a/janet/tmplt/src/app.janet b/janet/tmplt/src/app.janet index f67e8e3..f28aaf8 100644 --- a/janet/tmplt/src/app.janet +++ b/janet/tmplt/src/app.janet @@ -1,18 +1,3 @@ -(defn sum3 - "Solve the 3SUM problem in O(n^2) time." - [s] - (def tab @{}) - (def solutions @{}) - (def len (length s)) - (for k 0 len - (put tab (s k) k)) - (for i 0 len - (for j 0 len - (def k (get tab (- 0 (s i) (s j)))) - (when (and k (not= k i) (not= k j) (not= i j)) - (put solutions {i true j true k true} true)))) - (map keys (keys solutions))) -(let [arr @[2 4 1 3 8 7 -3 -1 12 -5 -8]] - (printf "3sum of %j: " arr) - (printf "%j" (sum3 arr))) \ No newline at end of file +(defn add [a b] + (+ a b)) \ No newline at end of file diff --git a/janet/tmplt/test/sum.janet b/janet/tmplt/test/sum.janet index be82870..3086324 100644 --- a/janet/tmplt/test/sum.janet +++ b/janet/tmplt/test/sum.janet @@ -1,4 +1,4 @@ (use /src/app) (use judge) -(test (sum3 arr)) \ No newline at end of file +(test (add 2 3) 4) \ No newline at end of file -- cgit 1.4.1-2-gfad0