Added new benches and will add the rest of them

This commit is contained in:
Sharjeel Khan
2022-11-08 22:49:43 -05:00
parent 7eb8465f64
commit a7248daca0
7 changed files with 127 additions and 2 deletions

View File

@@ -8,7 +8,7 @@ exec pil $0 $1
(de fib (N) (cond ((= 0 N) 1)
((= 1 N) 1)
(1 (let (A (fib (- N 1))
(T (let (A (fib (- N 1))
B (fib (- N 2))
) (+ A B)))))

View File

@@ -8,6 +8,6 @@ exec pil $0 $1
(de fib (n) (cond ((= 0 n) 1)
((= 1 n) 1)
(1 (+ (fib (- n 1)) (fib (- n 2))))))
(T (+ (fib (- n 1)) (fib (- n 2))))))
(bye (println (fib (car (str (opt))))))

View File

@@ -0,0 +1,37 @@
#!/usr/bin/env bash
#{
# Thanks to http://rosettacode.org/wiki/Multiline_shebang#PicoLisp
exec pil $0 $1
# }#
(de safe (Q D S) (let (C (car S))
(case C
(NIL T)
(T (and (<> Q C) (<> Q (+ C D)) (<> Q (- C D)) (safe Q (+ D 1) (cdr S)) ))
)
)
)
(de appendS (Q S X) (cond ((<= Q 0) X)
((safe Q 1 S) (appendS (- Q 1) S (cons (cons Q S) X)))
(T (appendS (- Q 1) S X) )
)
)
(de extendS (Q A X) (let (S (car X))
(case S
(NIL A)
(T (extendS Q (appendS Q S A) (cdr X)))
)
)
)
(de findS (N Q) (cond ((= 0 Q) (cons (cons NIL NIL) NIL))
(T (extendS N NIL (findS N (- Q 1))))))
(de nqueens (N) (length (findS N N)))
(bye (println (nqueens (car (str (opt))))))