aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHVukman <peterslopp@googlemail.com>2025-06-29 17:58:28 +0200
committerGitHub <noreply@github.com>2025-06-29 17:58:28 +0200
commit00da354b49482bd67ca82dc75ae919e7aa852688 (patch)
tree7723ad19216bd004ae464790a4e6e0c740bfb2aa
parent2901fdd419eeaf5aa57c259202bdaf716277b85e (diff)
downloadperlweeklychallenge-club-00da354b49482bd67ca82dc75ae919e7aa852688.tar.gz
perlweeklychallenge-club-00da354b49482bd67ca82dc75ae919e7aa852688.tar.bz2
perlweeklychallenge-club-00da354b49482bd67ca82dc75ae919e7aa852688.zip
Add files via upload
-rw-r--r--challenge-327/hvukman/picolisp/327_p2.l66
1 files changed, 66 insertions, 0 deletions
diff --git a/challenge-327/hvukman/picolisp/327_p2.l b/challenge-327/hvukman/picolisp/327_p2.l
new file mode 100644
index 0000000000..e2519e6d59
--- /dev/null
+++ b/challenge-327/hvukman/picolisp/327_p2.l
@@ -0,0 +1,66 @@
+(de flatten (X)
+ (fish atom X) )
+
+
+(de mad (arg)
+(car (filter '( (X) (< 0 X)) (sort (uniq (flatten (make
+ (for XX arg
+ (link (mapcar '( (x) (abs (- XX x)) ) arg) )
+ )
+ )
+ )
+ )
+ ))
+)
+)
+
+(setq inp (4 1 2 3))
+(setq list_mad (mad inp))
+(println "MAD: " list_mad)
+
+(setq 'ZZ NIL)
+
+(de sol (X)
+(make
+ (for x X
+ (for y X
+ (if (= list_mad (abs (- x y) ))
+ (let (dummy NIL key1 (sym x) key2 (sym y))
+
+ #(println (get 'ZZ key1))
+ #(println (get 'ZZ key2))
+ (cond
+ (
+ (and (= NIL (get 'ZZ key1)) (= NIL (get 'ZZ key2 )))
+
+ (put 'ZZ key2 x)
+ #(println (list x y))
+ #(println "@ " (mapcar car (made)))
+ (if (= NIL (member y (flatten (mapcar car (made)))))
+ (link (list x y))
+ )
+
+ )
+ (T )
+ )
+ )
+ )
+ )
+ )
+)
+)
+
+
+(println (sol inp))
+
+(setq inp (1 3 7 11 15))
+(setq list_mad (mad inp))
+(println "MAD: " list_mad)
+(setq 'ZZ NIL)
+(println (sol inp))
+
+(setq inp (1 5 3 8))
+(setq list_mad (mad inp))
+(println "MAD: " list_mad)
+(setq 'ZZ NIL)
+(println (sol inp)) \ No newline at end of file